Quick search

Source code for sqlobject.tests.test_SingleJoin

[docs]classPersonWithAlbum(SQLObject):name=StringCol()# albumNone returns the album or nonealbumNone=SingleJoin('PhotoAlbum',joinColumn='test_person_id')# albumInstance returns the album or an default album instancealbumInstance=SingleJoin('PhotoAlbum',makeDefault=True,joinColumn='test_person_id')

[docs]deftest_1():setupClass([PersonWithAlbum,PhotoAlbum])person=PersonWithAlbum(name='Gokou (Kakarouto)')# We didn't create an album, this way it returns Noneassertnotperson.albumNoneassertisinstance(person.albumInstance,PhotoAlbum)PhotoAlbum(person=person)assertperson.albumNoneassertisinstance(person.albumNone,PhotoAlbum)assertisinstance(person.albumInstance,PhotoAlbum)