DSMLParser example
Yves Dorfsman
yves at zioup.com
Wed Dec 17 15:36:19 CET 2008
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
More information about the python-ldap
mailing list