On Tuesday 20 March 2007 03:17, [EMAIL PROTECTED] wrote:
> 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/sqlobj
>ect/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/sqlobj
>ect/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/templ
>ates/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 :)
You stumbled over one of the less-intuitive corners of SO, which I personalyl
don't understand either - there should be ways to implement that different.
However, in the moment you have to do it like this:
accounts = MTAccount.select(MTAccount.q.userID == identity.current.user.id)
Diez
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---