[SQLObject] relationship interface and lists..
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Bud P. B. <bu...@si...> - 2003-05-20 12:18:06
|
I've been thinking about the API for dealing with relations. person.roles is just perfect. In addition, what about person.rolesWhere(<some condition>) And instead of person.addRole(r), what about person.roles.append(r) and similarly, r.removePerson(p) as r.persons.remove(p) To be pythonic, everything should behave as much as a list as possible. So I started to play around with inheriting from list and looking at the hooks (see attached file). I was expecting that there was a single interface to setting and getting list items (namely, __getitem__ and __setitem__), but it seems that other ways of modifying the list such as l.extend() or l.append() don't internally fall back on __getitem__ and __setitem__. Also, someone could "recalculate" relationships and assign them: p.roles = throttleBack(p.roles) Has any of you looked into these issues and knows which hooks have to be taken care of? thanks --bud /----------------------------------------------------------------- | Bud P. Bruegger, Ph.D. | Sistema (www.sistema.it) | Via U. Bassi, 54 | 58100 Grosseto, Italy | +39-0564-411682 (voice and fax) \----------------------------------------------------------------- |