Comments (7)
Hi Giovanni!
I think this is the same regression as we discussed lately. Can you please add the .hasValue()
check in addition to is None
you have like this:
'saslCreds': bytes(response['serverSaslCreds']) if response['serverSaslCreds'] is not None and response['serverSaslCreds'].hasValue() else None}
I'm here to fix whatever regression the latest release may have caused. %-\
from pyasn1.
I'm adding a lot of if request['xxx'] is not None and request['xxx'].hasValue() else None
to the ldap3 code. I think that there should be a better way to do this. With the previous pyasn1 versions the uninitialized value were all None. There is a way to have the same behaviour?
from pyasn1.
Well, I'm not sure how to handle this in a backward compatible way... The ultimate goal is to make the whole API more "automatic" and compact. For example, imagine a nested structure like this:
LDAPMessage ::= SEQUENCE {
messageID MessageID,
protocolOp CHOICE {
bindRequest BindRequest,
...
intermediateResponse IntermediateResponse },
controls [0] Controls OPTIONAL }
BindRequest ::= [APPLICATION 0] SEQUENCE {
version INTEGER (1 .. 127),
name LDAPDN,
authentication AuthenticationChoice }
Now you want to initialize it. With previous pyasn1 API you could only do that in multiple steps, from outer to inner elements:
ldap = LDAPMessage()
ldap.setComponentByName('protocolOp') # this instantiates CHOICE
ldap['protocolOp'].setComponentByName('bindRequest') # this instantiates BindRequest
ldap['protocolOp']['bindRequest'].setComponentByName('version', 1) # this instantiates INTEGER
The new API is more compact and intuitive:
ldap = LDAPMessage()
ldap['protocolOp']['bindRequest']['version'] = 1
The compact version can only work if ldap['protocolOp']
returns CHOICE
instance, not None
for uninitialized field.
WDIT? Your advise is much appreciated!
BTW, if you make pyasn1 >= 0.3.1 a requirement, you could omit the request['xxx'] is not None
part and leave just request['xxx'] if request['xxx'].isValue else None
. The is not None
part is only required if you want the code to work with both pyasn1 API flavours.
from pyasn1.
Thanks Ilya, I've been able to fix all errors in ldap3 tests. Now my codes works with pyasn1 froom version 0.1.8 up to 0.3.1. Prior to 0.1.8 the hasValue() method is absent.
from pyasn1.
Thank you, Giovanni! And sorry for the trouble. ;)
I'd also appreciate if you run your test with the current pyasn1 master (which is about to be released as 0.3.2). I do not expect any breakage there though.
Prior to 0.1.8 the hasValue() method is absent.
I believe 0.1.8 is so much historical now days. I can potentially propose a compatibility measure to make ldap3 running with older pysn1. Let me know if you need that.
from pyasn1.
I've tested the 0.3.2 branch, everything is ok, all tests pass!
from pyasn1.
Great, thank you!
from pyasn1.
Related Issues (20)
- 0.4.8: sphinx warning
- 0.4.8: pytest warning
- Stacktrace when enabling debugging
- 0.4.8: pyasn1-module pytest warnings
- KeyError when processing some PySNMP MIB modules HOT 1
- Need "Questions" enabled on GitHub? HOT 2
- Decoded object results in empty infinitely nested SequenceOf HOT 1
- Error on connection bind pyasn1 version 0.4.8 and 0.4.6
- http://snmplabs.com is domain parked HOT 2
- do you have plan HOT 1
- Unexpected error with tagging
- [PSA] Transfer of ownership HOT 1
- parsing LDAP search message openldap HOT 1
- Sad news and transfer of ownership - pyasn1 and pyasn1-modules
- Merging ASN.1 files HOT 1
- Is pyasn1 v0.4.8 is compatible with python3.11 HOT 2
- is it support python 3.6 ? HOT 1
- Attempted "__hash__" operation on ASN.1 schema object
- pyasn1.error.PyAsn1Error: Read 100 bytes instead of expected 92 HOT 2
- Link to ftp.rsasecurity.com is broken HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyasn1.