Neil Blakey-Milner wrote:
> On 3/15/07, Richard Harding <[EMAIL PROTECTED]> wrote:
>> I've been playing with moving my little project to use Genshi. My
>> trouble is that I'm getting the following error:
>>
>> AttributeError: 'unicode' object has no attribute 'namespace'
>
> I had the same problem when installing a new instance of TG. The
> weirdness is that I got Genshi-0.4dev_r509-py2.4.egg when using
> setuptools/easy_install to install TurboGears - I'm pretty sure the
> dev packages shouldn't be linked to from a "stable" build of TG.
>
> But I didn't have time to debug why I got the dev version - it was
> actually simpler to write a quick patch. The following replacement to
> the "ET" function works for me:
>
> from genshi.core import Attrs, QName, Stream, stripentities
> from genshi.core import DOCTYPE, START, END, START_NS, END_NS, TEXT, \
> START_CDATA, END_CDATA, PI, COMMENT
> def myET(element):
> """Convert a given ElementTree element to a markup stream."""
> tag_name = QName(element.tag.lstrip('{'))
> attrs = Attrs((QName(k), v) for k, v in element.items())
>
> yield START, (tag_name, attrs), (None, -1, -1)
> if element.text:
> yield TEXT, element.text, (None, -1, -1)
> for child in element.getchildren():
> for item in myET(child):
> yield item
> yield END, tag_name, (None, -1, -1)
> if element.tail:
> yield TEXT, element.tail, (None, -1, -1)
>
> The only difference is that before the attrs line was:
>
> attrs = Attrs(element.items())
>
> And I put in:
>
> attrs = Attrs((QName(k), v) for k, v in element.items())
>
> I haven't added a bug report to Genshi for this yet - do you mind
> doing this and attaching the "fix"?
>
> Cheers,
>
> Neil
Thanks, this is exactly what I need (I think). Idiot question of the
day. I'm new to eggs/easy_install (thank you apt-get) so if anyone can
give me the 30sec view of what needs to be done to edit the file I'd
appreciate it. I'm guessing break open the egg/edit the file/rebuild the
egg?
Thanks
Rick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---