The best I can come up with is to use SQLObjects 'magic attributes'
functionality to fake the foreign key reference.  An example:

from turbogears.identity.model.somodel import User

class myUser(SQLObject):

    fk_to_user = IntCol()

    def _get_user(self):
        return User.get(self.fk_to_user)

    def _set_user(self, user_obj):
        self.fk_to_user = user_obj.id

    def _del_user(self):
        u=User.get(self.fk_to_user)
        u.destroySelf()
        self.fk_to_user = None

    # Other things you want to implement in your class...

Unless SQLObject defines a way to access other registry classes (which
I couldn't find), I think that's your simplest solution.  If your
database supports it, it may be worthwhile to set up the foreign key
reference in your db schema, just to be sure.

Reply via email to