This module provide an easy way to deal with ldap stuff in python.
Project description
This module is actively used on http://www.afpy.org to manage the french python comunity members.
Get a connection (this custom afpy connection get is configuration from a ~/.ldap.ini file):
>>> from afpy.ldap import custom as ldap >>> conn = ldap.get_conn()
Get a node via is dn:
>>> dn = 'uid=gawel,ou=members,dc=afpy,dc=org' >>> node = conn.get_node(dn) >>> node <Node at uid=gawel,ou=members,dc=afpy,dc=org> >>> print node.birthDate 19750410000000Z
You can also define your own node class with a schema:
>>> from afpy.ldap.node import Node >>> from afpy.ldap import schema >>> class User(Node): ... uid=schema.StringProperty('uid') ... birthDate = schema.DateProperty('birthDate', title='Date de naissance') >>> node = conn.get_node(dn, node_class=User) >>> node <User at uid=gawel,ou=members,dc=afpy,dc=org>
Then data is converted to a python object:
>>> node.birthDate datetime.date(1975, 4, 10)
This also allow to generate forms with FormAlchemy:
>>> from afpy.ldap import forms >>> fs = forms.FieldSet(User) >>> user = User() >>> fs.rebind(user) >>> print fs.render().strip() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE <div> <label class="field_opt" for="User--uid">uid</label> <input id="User--uid" name="User--uid" type="text" /> </div> ... <div> <label class="field_opt" for="User--birthDate">Date de naissance</label> ...
The source code can be find on the AFPy repository
Got a bug, feature request ? Want to send beer because you love it ? Send an email at afpy-web@lists.afpy.org
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
afpy.ldap-0.3.tar.gz
(25.9 kB
view details)
File details
Details for the file afpy.ldap-0.3.tar.gz
.
File metadata
- Download URL: afpy.ldap-0.3.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3724df76ddee1490925b35b447d601de8062bbd01e4b0b2efccf076c7608fe0 |
|
MD5 | 6c70f33baf4b41be7d4f60b25a16204c |
|
BLAKE2b-256 | 62a66086a9f20dc8cf4a6fe65085a90a2feb712abcb61c1afa3a46384666ce0b |