On Mon, 19 Mar 2007 at 20:47, [EMAIL PROTECTED] wrote:
> On Mon, 19 Mar 2007 at 21:00, Jorge Godoy wrote:
>> Using SQL Object:
>>
>> data = model.Class.select(model.Class.q.user == identity.current.user)
>>
>> So, when you retrieve something it will be filtered by the user_id column on
>> your database.
>
> Thanks, that pointer saves me some time :)
Then, again, maybe not. Using
accounts = MTAccount.select(MTAccount.q.user == identity.current.user)
I get:
File
"/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/sqlbuilder.py",
line 356, in __getattr__
raise AttributeError("%s instance has no attribute '%s'" %
(self.soClass.__name__, attr))
AttributeError: MTAccount instance has no attribute 'user'
My class looks like this:
class MTAccount(SQLObject):
user = ForeignKey('User')
label = UnicodeCol()
description = UnicodeCol()
accountnumber = UnicodeCol()
def __str__(self): return self.label
I nudged around with tg-admin shell and got the same error message.
I saw that the repr for an object has the field userID instead of
user, which makes sense (though the AttributeError above could be
clearer). But when I use that:
accounts = MTAccount.select(MTAccount.q.userID == identity.current.user)
I get this:
File
"/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/converters.py",
line 220, in sqlrepr
raise ValueError, "Unknown SQL builtin type: %s for %s" % \
ValueError: Unknown SQL builtin type: <class
'moneytracker.identity.model.User'> for <User 1 user_name=u'bitdancer'
email_address="u'[EMAIL PROTECTED]'" display_name=u'bitdancer'
password=u'testthis' created='datetime.datetime...)'>
Error in code generated from template file
'/var/www/finance.bitdance.com/moneytracker/moneytracker/moneytracker/templates/oneform.kid'
Googling for this error didn't get me any relevant hits. I'm pretty
sure this represents something basic I don't yet know about SQLObject,
but I must say that the error message is pretty mystifying at this
point :)
Which means it's time to quit for the night....
--David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---