I like to give my MultipleJoin columns the name 'children' to give a uniform
way to access the associated objects. But SQLObject 0.6 ignores my class
attribute name:
from sqlobject import *
__connection__ = 'sqlite:///tmp/test.db'
class Composer(SQLObject):
name = StringCol()
children = MultipleJoin('Work')
class Work(SQLObject):
composer = ForeignKey('Composer')
title = StringCol()
for klass in Composer, Work:
klass.dropTable(ifExists=True)
klass.createTable(ifNotExists=True)
c = Composer(name='Beethoven, Ludwig van')
w = Work(composer=c, title='Symphony No. 7')
print c.works
print c.children
This gives the result:
[<Work 1 composerID=1 title='Symphony No. 7'>]
Traceback (most recent call last):
File "<stdin>", line 23, in ?
AttributeError: 'Composer' object has no attribute 'children'
|