[SQLObject] Auto-relationship one-to-many
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Leandro M. de S. <lea...@gm...> - 2007-01-24 19:04:24
|
Hi list, I have a class named Container. One Container may have one or more containers determining a auto-relationship (one-to-many). I'm doing this like this: class Container(InheritableSQLObject): title = StringCol() container = ForeignKey('Container') containers = MultipleJoin('Container') def __init__(self, *args, **kwargs): SQLObject.__init__(self, *args, **kwargs) Container.sqlmeta.addJoin(MultipleJoin('Container', joinMethodName='containers')) But when I do: 1: container1 = Container(title="the title") 2: container2 = Container(title="the title") 3: 4: container1.addContainer(container2) I got the following error at line 1: raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, col.name) TypeError: Container() did not get expected keyword argument containerID Does someone can help or tell me the right way to implement an auto-relationship? Thank you, Leandro. |