Skip to main content

This module provide an easy way to deal with ldap stuff in python.

Project description

afpy.ldap

This module is actively used on http://www.afpy.org to manage the french python comunity members.

The following examples show all features of the package. If you just want to give it a try in a quickest way read Installation and configuration from the Sphinx documentation.

Get a connection (this custom afpy connection get is configuration from a ~/.ldap.ini file. See Installation and configuration):

>>> 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

News

0.8

  • small fixes

  • add GroupOfUniqueNames

0.7

  • Add repoze.what plugins

  • Allow to set node classes via config file

  • fix compat with latest python-ldap

0.5

  • require dataflake.ldapconnection>=1.0b1, python-ldap>=2.3.10

0.1

  • initial version

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.8.tar.gz (37.1 kB view details)

Uploaded Source

File details

Details for the file afpy.ldap-0.8.tar.gz.

File metadata

  • Download URL: afpy.ldap-0.8.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for afpy.ldap-0.8.tar.gz
Algorithm Hash digest
SHA256 aced24f5c23f7422101e52d801996041e459de9e59dc3124d3b072b9104bda5f
MD5 1b1c635c2e853c453f6c08029bcf07b4
BLAKE2b-256 62f3bbb1a726e1709b69e010bfb5ce5a6293da2a9bc3608fbcc3a330fee19e3c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page