On Mon, May 08, 2006 at 02:28:03PM +0200, Felix wrote: > Hi everyone !! > > I've a question (sorry if the email subject isn't to explicative) that i will > simplify in this example: > > Three simple tables with relations: > > class rank(SQLObject):
Python code almost always has Capitalised class names (See also http://www.python.org/dev/peps/pep-0008/), i.e. "class Rank(SQLObject):". This will help make something else clearer: > id = IntCol() > title = StringCol() > persons = MultipleJoin('person') > > class kind(SQLObject): > id = IntCol() > kindName = StringCol() > persons = MultipleJoin('person') > > class person(SQLObject): > id = IntCol() > name = StringCol() > rankID = ForeignKey('rank') > kindID = ForeignKey('kind') Make these last two lines be just: rank = ForeignKey() kind = ForeignKey() (and if you name the classes "Rank" and "Kind", then there's no possible confusion to worry about here). > > What's the best way to get title and kindName instead rankID and kindID if i > do person.get(1).select() (or else)? > With SQL queries i would do subslects or joins. Person.get(1).rank.title Person.get(1).kind.kindName > I think i could access through something like rank.persons or can i override > _get_rankID() for getting rank title instead > rankID or add new fields in person class like: Right, you can make properties to be shortcuts to the above code snippets. -Andrew. ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ sqlobject-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
