From: Cristian S. R. <cr...@dc...> - 2003-11-13 20:04:17
|
Hi, Traying to use the DSML writer as the LDIF writer with the async module, with the following code, I changed some lines in the dsml.py and async.py files. s = ldap.async.DSMLWriter( ldap.initialize('ldap://%s' % host), sys.stdout ) s.startSearch( base, ldap.SCOPE_SUBTREE, '(objectClass=*)', ) I checked out the files from the CVS and I changed them. It's working fine. For commit them in the CVS, I attached them in the mail. Bye, Cristian. PD: Sorry by my bad english. I hope you understand it ;) |
From: <mi...@st...> - 2003-11-14 09:53:46
|
Cristian Sebastian Rocha wrote: > > Traying to use the DSML writer as the LDIF writer with the async module, with > the following code, I changed some lines in the dsml.py and async.py files. Thanks for sending a patch. Next time please provide some more details what you've changed. This enhances the chance that I don't defer changes due to my momentary work-load. From looking at the diff it seems to me that you simply changed the nameof the class attribute DSMLWriter._f to DSMLWriter._output_file. Is that right? Ah, you also changed the name of the method DSMLWriter.writeRecord() to DSMLWriter.unparse(). Off course this breaks existing code. Therefore I simply added a new wrapper method DSMLWriter.unparse(). I've checked in the changes. Please test! Ciao, Michael. |
From: Cristian S. R. <cr...@dc...> - 2003-11-14 12:45:33
|
Michael, You are right. I just made two changes: 1) DSMLWriter._f -> DSMLWriter._output_file 2) DSMLWriter.writeRecord() -> DSMLWriter.unparse() I will test the changes later. Thanks, Cristian. El vie, 14-11-2003 a las 06:53, Michael Str=F6der escribi=F3: > Cristian Sebastian Rocha wrote: > >=20 > > Traying to use the DSML writer as the LDIF writer with the async = module, with > > the following code, I changed some lines in the dsml.py and async= .py files. >=20 > Thanks for sending a patch. Next time please provide some more deta= ils what > you've changed. This enhances the chance that I don't defer changes= due to > my momentary work-load. >=20 > From looking at the diff it seems to me that you simply changed th= e nameof > the class attribute DSMLWriter._f to DSMLWriter._output_file. Is th= at right? >=20 > Ah, you also changed the name of the method DSMLWriter.writeRecord(= ) to > DSMLWriter.unparse(). Off course this breaks existing code. Therefo= re I > simply added a new wrapper method DSMLWriter.unparse(). >=20 > I've checked in the changes. Please test! >=20 > Ciao, Michael. >=20 >=20 >=20 > ------------------------------------------------------- > This SF.Net email sponsored by: ApacheCon 2003, > 16-19 November in Las Vegas. Learn firsthand the latest > developments in Apache, PHP, Perl, XML, Java, MySQL, > WebDAV, and more! http://www.apachecon.com/ > _______________________________________________ > Python-LDAP-dev mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-ldap-dev --=20 Cristian S. Rocha <cr...@dc...> Departamento de Computaci=F3n - Universidad de Buenos Aires |
From: Cristian S. R. <cr...@dc...> - 2003-11-27 14:28:27
|
Hi, I'm here again. I would like to do more modifications but the async module will change a lot, before I want to ask you what do you think about some modifications. At now the async code is dependent to the format output: exists two classes to output ldif (ldif.LDIFWriter & ldap.async.LDIFWriter) and another two for dsml (dsml.DSMLWriter & ldap.async.DSMLWriter). I want to propose just one class for output (ldap.async.Writer) and other two for format considerations (dsml.DSMLWriter & ldif.LDIFWriter). That let you to output both format with less changes on the code. An example could be: """ format = { 'dsml': dsml.DSMLWriter(sys.stdout), 'ldif': ldif.LDIFWriter(sys.stdout), } def print(host, base, filtre, formatstr): s = ldap.async.Writer( ldap.initialize(host), format[formatstr] ) s.startSearch( base, ldap.SCOPE_SUBTREE, filtre ) """ To do it, the classes must share the following interface: """ class XWriter: def __init__(self, f, ...): """ Init the writer class. f file object for output. """ ... return def header(self): """ Return a header string. """ ... return '' def footer(self): """ Return a footer string. """ ... return '' def unparse(self, dn, entry): """ Write the entry to the object for output. dn string-representation of distinguished name entry dictionary holding the LDAP entry {attr:data} """ ... return """ I just append these functions (header & footer) to the LDIFWriter and DSMLWriter classes in "ldif.py" and "dsml.py" files. I append the async.Writer class to use the interface in the "async.py" file. And I test the code with the "Test.py" program. All the files are attached on the mail. Regards to all, Cristian. -- Lic. Cristian S. Rocha. <cr...@dc...> Departamento de Computacin. FCEyN. UBA. Pabellon I. Cuarto 9. Ciudad Universitaria. (1428) Buenos Aires. Argentina. Tel: +54-11-4576-3390/96 int 714 Tel/Fax: +54-11-4576-3359 Cel: 15-5-607-9192 |
From: <mi...@st...> - 2003-11-27 21:08:32
|
Cristian S. Rocha wrote: > > I'm here again. I would like to do more modifications but the async > module will change a lot, before I want to ask you what do you think > about some modifications. I already started a new module 'ldap.res' since I wanted to fix some mistakes I did in the design but keep the module ldap.async as is for not breaking existing code (mainly web2ldap and some sync scripts I've implemented for my customers). I think this is the way to go. From what I understand you're after the same thing like me: The data read by an arbitrary XReader should be piped to an arbitrary YWriter. With this you would be able to pump data from DSML to LDAP server, convert from LDIF to DSML, etc. Note that the Java implementation of Novell found on http://www.openldap.org implements classes with common interfaces. We might be able to borrow some ideas from this project. Also note that the modules 'ldif' and 'dsml' (and 'ldapurl') implemented in pure Python were designed to be usable stand-alone without importing anything from the rest of python-ldap. I found this handy on some platforms on which it's difficult to build the C wrapper part in cases I only needed a LDIF parser. So maybe best bet is to implement a new module package with interchangeable Reader/Writer classes and import and wrap the modules ldap, ldif and dsml. Not to forget implementing CSVReader/-Writer classes (with module 'csv' available in Python standard lib 2.3+). Speaking of module 'csv' it would also be nice to let the Reader classes implement the iterator interface available since Python 2.2. Look into the Python 2.3 'csv' docs to get the idea. I have currently no time do that myself but I'd be glad to review contributed code. How does that sound to you? Ciao, Michael. |