Hi Dane,

thank you for your answer! I installed lxml and i can successfully import the 
bindings in python:
> import lxml.etree

I changed the corresponding code in cascadenik-compile.py:
> #try:
> #    import xml.etree.ElementTree as ElementTree
> #    from xml.etree.ElementTree import Element
> #except ImportError:
> try:
>     import lxml.etree as ElementTree
>     from lxml.etree import Element
> except ImportError:
>     import elementtree.ElementTree as ElementTree
>     from elementtree.ElementTree import Element

But still, I get a different error:
> cascadenik-compile.py example.mml > test.xml
> Traceback (most recent call last):
>   File "/usr/local/bin/cascadenik-compile.py", line 114, in <module>
>     sys.exit(main(layersfile, **options.__dict__))
>   File "/usr/local/bin/cascadenik-compile.py", line 46, in main
>     doc.write(f)
> AttributeError: 'lxml.etree._Element' object has no attribute 'write'


The corresponding code looks like:
>     if kwargs.get('pretty'):
>         doc = ElementTree.fromstring(open(filename, 'rb').read())
>         print doc
>         cascadenik._compile.indent(doc)
>         f = open(filename, 'wb')
>         doc.write(f)
>         f.close()

I have never worked with lxml yet, but it seems weird: the _Element Class 
doesn't has a write function, see
> http://codespeak.net/lxml/api/lxml.etree._Element-class.html

But the ElementTree does it, and I think this was in mind.
> http://codespeak.net/lxml/api/lxml.etree._ElementTree-class.html

Well, the pretty option didn't seem to be important, I skipped the if block and 
now compile.py works without errors. I assume this change doesn't affect the 
result, I will have to check it!

Thanks Dane for your help, If i can contribute anything to fix this bug, let me 
know!

Bye,
Christoph

Am 03.11.2010 um 00:21 schrieb Dane Springmeyer:

> Hi Christoph,
> 
> Yes, sorry this is a bug, fixed in the Cascadenik development version (but I 
> don't recommed using the dev version yet).
> 
> Basically it looks like you are using the latest release via pypi and in that 
> version there are several imports at the top of cascadenik/compile.py which 
> attempt to allow fallbacks to different xml parsers that implement an etree 
> interface.
> 
> lxml (python bindings to libxml2) is preferred and it turns out its interface 
> is slightly different and while it has doc.write() others may not.
> 
> So, the easiest way to fix this issues is to install lxml. On ubuntu I think 
> that is:
> 
> sudo apt-get install python-lxml
> 
> Dane
> 
> 
> On Nov 2, 2010, at 2:10 PM, Christoph Lingg | komoot wrote:
> 
>> Hi list,
>> 
>> I recently installed cascadenik on a new server and encountered an error 
>> while compiling my mml file. First I thought this might be due a wrong mml 
>> file, but even the example given by cascadenik doesn't work:
>> 
>>> christ...@server:~/mapnik-Cascadenik-796acf2$ cascadenik-compile.py 
>>> example.mml > test.xml
>>> Traceback (most recent call last):
>>>   File "/usr/local/bin/cascadenik-compile.py", line 114, in <module>
>>>     sys.exit(main(layersfile, **options.__dict__))
>>>   File "/usr/local/bin/cascadenik-compile.py", line 46, in main
>>>     doc.write(f)
>>> AttributeError: _ElementInterface instance has no attribute 'write'
>> 
>> 
>> I am quite lost and would be very happy if somebody knows more about this 
>> issue!
>> 
>> Thanks a lot in advance!
>> Christoph
>> 
>> PS:
>> I am running Ubuntu 10.10 and the content of test.xml looks like:
>>> cat test.xml
>>> <Element Map at 26c7fc8>
>> 
>> _______________________________________________
>> Mapnik-users mailing list
>> [email protected]
>> https://lists.berlios.de/mailman/listinfo/mapnik-users

_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to