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 |