If you are using TG2 or 1.5 check the SQLAlchemy docs, you can have a
foreign key defined (as an integer) and declare a relationship which
SQLAlchemy can load as needed or even with a join the referenced table
object, for example:
class ProjectRole(DeclarativeBase):
__tablename__ = "ProjectRole"
project_role_id = Column(Integer, primary_key=True)
name = Column(Unicode(64))
class Project(DeclarativeBase):
__tablename__ = "Project"
project_id = Column(Integer, primary_key=True)
project_role_id = Column(Integer, ForeignKey(ProjectRole.project_role_id))
project_role = relationship(ProjectRole)
Thus when you load a Project instance the project_role attribute is an
instance of ProjectRole, and you don't need to do anything more
SQLAlchemy does it for you.
Regards,
Carlos Ruvalcaba
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
turbogears+...@googlegroups.com.
> To post to this group, send email to
turbo...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/turbogears?hl=en.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>