Re: [SQLObject] Strange bug with SQLObject 0.6
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Michel T. <mic...@ya...> - 2004-10-16 03:28:14
|
Hi Carlos! I faced the same problem a day ago. This is a bug with Joins, you may pass a joinMethodName argument to solve this problem in your version, or update to a newer version from svn. I don't try the newer version, but, as Andrew Bennetts suggests me, I will try this weekend :) I hope I helped you, if I don't, you can mail me in portuguese (you are from python-brasil, aren't you?)... seeya --- Carlos Ribeiro <car...@gm...> escreveu: > Hello all. I'm writing a prototype using sqlobjects and sqlite, and > I've run into a strange problem. It may be a dumb mistake of mine (as > I often do :-), but I was not able to spot it. This is the test code: > > ----- > from sqlobject import connectionForURI, SQLObject, StringCol, IntCol, > \ > FloatCol, ForeignKey, MultipleJoin > > db = connectionForURI('sqlite:/work/test.db') > > class dbWorkItem(SQLObject): > _connection = db > wi_name = StringCol(length = 60, notNone = True) > wi_description = StringCol(length = 200, notNone = True, default > = '') > wi_form_class = StringCol(length = 40, notNone = True) > wi_form_id = IntCol(default=0) > owner = ForeignKey('dbUser') > workflow = ForeignKey('dbWorkFlow') > > class dbUser(SQLObject): > _connection = db > user_nickname = StringCol(length = 15, notNone = True, > alternateID = True) > user_password = StringCol(length = 15, notNone = True, default = > '') > user_name = StringCol(length = 40, notNone = True, default = > '') > user_address1 = StringCol(length = 40, notNone = False, default > = '') > user_address2 = StringCol(length = 40, notNone = False, default > = '') > user_city = StringCol(length = 40, notNone = False, default > = '') > user_comments = StringCol(length = 400, notNone = False, default > = '') > workitems = MultipleJoin('dbWorkItem') > > def new_db(): > dbUser.createTable() > dbWorkItem.createTable() > dbUser(user_nickname="cribeiro", user_name="Carlos Ribeiro") > dbWorkItem(wi_name='task1', wi_description='Task 1', > wi_form_class='', workflow=None, owner=1) > dbWorkItem(wi_name='task2', wi_description='Task 2', > wi_form_class='', workflow=None, owner=1) > > >>> new_db() > >>> u = dbUser.get(1) > >>> u > <dbUser 1 user_address1='' user_password='' user_address2='' > user_city='' user_name='Carlos Ribeiro' user_nickname='cribeiro' > user_comments=''> > >>> u.workitems > Traceback (most recent call last): > File "<interactive input>", line 1, in ? > AttributeError: 'dbUser' object has no attribute 'workitems' > >>> u.user_name > 'Carlos Ribeiro' > >>> wi = dbWorkItem.get(1) > >>> wi > <dbWorkItem 1 wi_form_class='' wi_form_id=0 wi_name='Entra nota > fiscal' workflowID=None ownerID=1 wi_description='Entra nota fiscal'> > >>> wi.owner > <dbUser 1 user_address1='' user_password='' user_address2='' > user_city='' user_name='Carlos Ribeiro' user_nickname='cribeiro' > user_comments=''> > >>> wi.owner is u > True > > For some reason, I cant access the dbUser.workitems property. I tried > the example provided in the documentation (using Person and Address > entities), and it works. What am I missing here? > > -- > Carlos Ribeiro > Consultoria em Projetos > blog: http://rascunhosrotos.blogspot.com > blog: http://pythonnotes.blogspot.com > mail: car...@gm... > mail: car...@ya... > > > ------------------------------------------------------- > This SF.net email is sponsored by: IT Product Guide on > ITManagersJournal > Use IT products in your business? Tell us what you think of them. > Give us > Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find > out more > http://productguide.itmanagersjournal.com/guidepromo.tmpl > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > ===== -- Michel Thadeu Sabchuk Curitiba/PR _______________________________________________________ Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com/ |