[lxml-dev] list-like views?
Ian Bicking
ianb at colorstudy.com
Fri Jun 15 00:36:37 CEST 2007
In the atom wrapper I made, I expose a categories attribute on entries.
This returns a list (-like object) of the <category> elements. It
also lets you add and remove from that list to modify the entry.
I generally don't do this, as it feels a little too clever to me. The
list-like object isinstance(obj, list), but it's a subclass, and has a
different repr. But I still worry about confusion.
Anyway, I was thinking of adding something similar to HtmlElement for
.classes, which would expose the HTML classes. This way you wouldn't
have to have methods like has_class, add_class, and remove_class (or do
it manually with string manipulation). How does this sound? The class
I used is _LiveList, here:
https://svn.openplans.org/svn/TaggerStore/trunk/taggerstore/atom.py --
basically it just calls some callbacks everytime something is added or
removed from the list.
Ian
More information about the lxml-dev
mailing list