Menu

#209 More complete constructors for the bindery base classes

open
5
2007-03-18
2007-03-18
No

I'd to use Amara documents like "normal" Python objects.

Let's say I define a class "Foo" that maps <foo/> elements and want to be able to instantiate this class through "foo = Foo()" like I would do for any other class.

I would write my constructor as:

class Foo(bindery.element_base):
def __init__(self):
bindery.element_base()
## custom init here

Unfortunately, there is almost no meat in the constructor for bindery.element_base since its inits are usually done through doc.xml_create_element(u'foo') instead of using the constructor.

I'd suggest thus to move these inits from xml_create_element() into a fully self sufficient constructor so that people can create new elements using either one or the other.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB