From: Yves D. <yv...@zi...> - 2008-12-17 06:38:41
|
Is there a simple example for dsml.DSMLParser() somewhere ? I am trying to use it, but getting errors. The documentation does not explain what "ContentHandlerClass" is supposed to be. I have tried: x = dsml.DSMLParser(input_file, dsml.DSMLv1Handler) But eventually it fails with an HTTP 404 error... Thanks. -- Yves. http://www.sollers.ca/blog/2008/swappiness http://www.sollers.ca/blog/2008/swappiness/.fr |
From: Michael S. <mi...@st...> - 2008-12-17 10:16:23
|
Yves Dorfsman wrote: > Is there a simple example for dsml.DSMLParser() somewhere ? No, this module is rather unmaintained. IIRC it mainly works like module ldif: You should sub-class dsml.DSMLParser implementing a custom method .handle(). Note that it only supports DMSLv1 which is not what you want today. > I have tried: > x = dsml.DSMLParser(input_file, dsml.DSMLv1Handler) > > But eventually it fails with an HTTP 404 error... ??? Ciao, Michael. |
From: Yves D. <yv...@zi...> - 2008-12-17 14:36:24
|
Michael Ströder wrote: > Yves Dorfsman wrote: >> Is there a simple example for dsml.DSMLParser() somewhere ? > > No, this module is rather unmaintained. > > IIRC it mainly works like module ldif: You should sub-class > dsml.DSMLParser implementing a custom method .handle(). Note that it > only supports DMSLv1 which is not what you want today. I did subclass it, the Writer works (I manage to convert from ldfi to dsml), but I never get to use the handler method, because it fails when I try to parse(). > >> I have tried: >> x = dsml.DSMLParser(input_file, dsml.DSMLv1Handler) >> >> But eventually it fails with an HTTP 404 error... > > ??? Yes I was confused too. The documentation does not indicate what the ContentHandler should be... is dsml.DSMLv1Handler the right thing to put there ? File "./ieLDAP.py", line 106, in main parser.parse() File "/usr/lib/python2.5/site-packages/dsml.py", line 300, in parse self._parser.parse(self._input_file) File "/usr/lib/python2.5/site-packages/_xmlplus/sax/expatreader.py", line 109, in parse xmlreader.IncrementalParser.parse(self, source) File "/usr/lib/python2.5/site-packages/_xmlplus/sax/xmlreader.py", line 123, in parse self.feed(buffer) File "/usr/lib/python2.5/site-packages/_xmlplus/sax/expatreader.py", line 216, in feed self._parser.Parse(data, isFinal) File "/usr/lib/python2.5/site-packages/_xmlplus/sax/expatreader.py", line 395, in external_entity_ref "") File "/usr/lib/python2.5/site-packages/_xmlplus/sax/saxutils.py", line 524, in prepare_input_source f = urllib2.urlopen(source.getSystemId()) File "/usr/lib/python2.5/urllib2.py", line 124, in urlopen return _opener.open(url, data) File "/usr/lib/python2.5/urllib2.py", line 387, in open response = meth(req, response) File "/usr/lib/python2.5/urllib2.py", line 498, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python2.5/urllib2.py", line 425, in error return self._call_chain(*args) File "/usr/lib/python2.5/urllib2.py", line 360, in _call_chain result = func(*args) File "/usr/lib/python2.5/urllib2.py", line 506, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 404: Not Found -- Yves. http://www.sollers.ca/blog |
From: Michael S. <mi...@st...> - 2008-12-17 14:56:06
|
Yves Dorfsman wrote: > Michael Ströder wrote: >> Yves Dorfsman wrote: >>> But eventually it fails with an HTTP 404 error... >> ??? > > Yes I was confused too. > [..] > File "/usr/lib/python2.5/urllib2.py", line 506, in http_error_default > raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) > urllib2.HTTPError: HTTP Error 404: Not Found Maybe the underlying modules try to download a DTD via HTTP for DSMLv1 which is no longer available at the OASIS site? Frankly I'd recommend not to bother with DSMLv1 since OASIS does not support it anymore. Ciao, Michael. |
From: Yves D. <yv...@zi...> - 2008-12-18 05:27:56
|
Michael: Can you confirm this is the way it was supposed to be used, I mean, is this class the sort of argument that should be used for ContentHandler ? > Yves Dorfsman wrote: > >> I have tried: >> x = dsml.DSMLParser(input_file, dsml.DSMLv1Handler) I have noted your observation about dsml v1, and will look at the new version, and see how far I get into implementing that. -- Yves. |
From: Michael S. <mi...@st...> - 2008-12-18 09:30:21
|
Yves Dorfsman wrote: > Michael: Can you confirm this is the way it was supposed to be used, I mean, > is this class the sort of argument that should be used for ContentHandler ? > >> Yves Dorfsman wrote: >> >>> I have tried: >>> x = dsml.DSMLParser(input_file, dsml.DSMLv1Handler) > > I have noted your observation about dsml v1, and will look at the new > version, and see how far I get into implementing that. AFAIK DSMLv2 is not a simple data format anymore. The point is that you have to implement hooks for the LDAP operations. Similar problem with the yet unimplemented support for change records in LDIF. The concept should be the same. There are patches by Roland pending to be examined for the LDIF module. Ciao, Michael. |