Re: Python3 and LDAP

2009-09-24 Thread David Leonard




Yes, I think so. I outlined a plan somewhere.. 
The big compatibility problem is that where you once used Python2.x's
strings ("str") to pass binary data, you would now have to use
Python3's "bytes".
And, other places where you would pass strings (like for attribute
names) you might now have to pass unicode strings and python-ldap would
convert these to UTF-8 under the covers.
The other minor compatibility issue was that there is no 'int' in
Python3, only longs now, but that turns out to be hardly noticeable.

But going back to the bytes/string/unicode problem, I'd like to know if
anyone has 2to3 migration/porting experience and if they might share
some advice/wisdom.

d

Bruno Aguirre wrote:
My hability to code a Python module is limited. But im
glad to give a hand.
  
Looking in the list i saw that someone said that the actual Python-ldap
can be build for Python 3 modifying some lines. Is this possible? Ar
there alternatives?
  
  2009/9/9 Michael Strder mich...@stroeder.com
  
Bruno Aguirre wrote:

 Hi to all, I'd like to know if there's a version (alpha, beta or
stable)
 to use ldap in python 3.


There are still some things to consider. Please dig the mailing list's
archive
for some discussion.

Would you personally be willing to put some effort into the C extension
module
part?

Ciao, Michael.

  
  
  





--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf___
Python-LDAP-dev mailing list
Python-LDAP-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev


Python-LDAP for Python 3.0

2009-08-03 Thread David Leonard





I have been looking at how to build the _ldap module for python3.x.
It's a pretty straightforward binary port except for one major headache
with strings. 

So, here I'd like to propose and explain some API changes Python 3.x
users. I'm focused on the _ldap module right now, but the (pure python)
library modules will experience carry-on effects. 

These are my goals with the _ldap module:

  allow Python 2.x clients to keep working without changes
  dual environment support: both 2.x and 3.x build environments
  

First, the easy one: int() is gone in 3.x. The _ldap module uses int
objects to return asynchronous message IDs, and to define a bunch of
constants. In Python 3.0 longs look and act just like old ints but with
more precision, so there should be few, if any, visible problem with
regard to this change in the _ldap API. (Unless you are relying on
overflow effects, which sounds suspicious anyway.)

1. Python-ldap compiled for 2.x should continue to use
int for Message IDs and constants, but when compiled for 3.x will use
longs.


Next, and much harder to deal with is the
loss of str(). There is heavy reliance of str() objects by _ldap to
hold binary data, for attribute values. But, Python 3.0 does not have
an 8-bit str(). It has what 2.x used to called unicode(). For 8-bit
data we have a new type called bytes(). The issue is that conversion
between the two is not automatic.

For existing LDAP applications, I expect this to open up a world of
porting pain. This is because lots of actual attribute values are ASCII
and having the values available in a string type has been a very handy
convenience. But, strictly, it is wrong. LDAP attribute values are
binary OCTET STRINGs, and in the unicode-only text world of Python 3.x,
applications that want text will need to decode these binary strings in
accordance with the attribute's schema. This problem is
something I'd like feedback on.

Yet there is some good news. The text/binary problem appears to be
restricted just to attribute values and to some authentication
parameters like SASL passwords. Unaffected are attribute names, DNs and
search filters. This is because they are transmitted as the ASN.1
LDAPString type, which is a UTF-8 encoded OCTET STRING. So it makes
sense for the _ldap API to accept unicode strings for these. But,
attribute values (OCTET STRING) surely must become bytes().

Using the bytes() type is going to cause much pain with potentially
lots of "TypeError: Can't convert 'bytes' object to str implicitly"
messages everywhere. But, it seems that this is part-and-parcel of
porting to Python 3.x. If you really need strings, learn the encoding
types of your attributes and call str(value, "UTF-8") or str(value,
"ASCII") to convert them.

So, my other proposed API changes are:

2. Python-ldap compiled for 2.x should continue to
accept and produce strings as before.
3. When compiled for 3.x, values that are UTF-8 LDAPString on
the wire (attribute names, DNs, search filters, etc) should be
passed in and out as (unicode) strings. Attribute value data, and other
places where BER binary values are passed, should be passed in and out
as bytes(). There should be no automatic conversion between bytes() and
unicode str().
  

A library class that automatically converts attribute values of type
bytes() into various python types via an attribute schema is possible,
but at the _ldap level this is not necessary. It may even be better for
an application tightly coupled to an LDAP schema to do this conversion
itself.

In summary, python-ldap should have no API change visible to 2.x
clients. But, 3.x clients should need to use the bytes() type
explicitly for attribute values.

d




--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Python-LDAP-dev mailing list
Python-LDAP-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev


Re: Removing person names in python-ldap's source files

2008-03-20 Thread David Leonard
Michael Ströder wrote:
 HI!

 inspired by a presentation the Subversion guys gave (as Google tech talk) 
 I'd like to remove all person names from the source code files. Instead 
 authors/contributors are all listed in README.

 I already removed *my* name from all the python modules it appeared in. Now 
 I'd like to ask for the permission, especially by David, to remove all other 
 person names from the files Modules/*.

   

Hi, Michael - sorry for the delay, I have been vacationing.

Is the tech talk presentation online? It sounds like a good idea; please 
move my name out of source files.: you have my permission. The commit 
info is probably going to be sufficient :)

Also, I added python-ldap to ohloh (http://www.ohloh.net/projects/11988)

d


-- 
David Leonard   [EMAIL PROTECTED]
Ph:+61 404 844 850


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Python-LDAP-dev mailing list
Python-LDAP-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev


Re: Creating Active Directory Objects

2007-11-08 Thread David Leonard

Michael Ströder wrote:

David Leonard wrote:
  

I hope someone else can
chime in here with an example of sasl binds with python-ldap.



See: Demo/sasl_bind.py

  


oops, of course! thanks michael :)

--
David Leonard   [EMAIL PROTECTED]
   Ph:+61 404 844 850

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now  http://get.splunk.com/___
Python-LDAP-dev mailing list
Python-LDAP-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev