Hey people, I hate to be pushy but I was wondering if anyone could provide any
insight in to this at
all? It's currently a major stumbling block in my app's development :'(
Thanks in advance
-Rob
Robin Haswell wrote:
> Hey guys
>
> I was wondering if you could give me a hand with an SO problem I've run in
> to. I'm building a search
> mechanism for my database. This is what my model (essentially) looks like:
>
> class Player(SQLObject):
> firstname = StringCol(length=255)
> lastname = StringCol(length=255)
> fullname = DatabaseIndex("firstname", "lastname", unique=True)
>
> # ..snip..
>
> passing = IntCol()
>
> forsale = SingleJoin("PlayerForSale") # Don't really want this here,
> thought I might as well
>
> class PlayerForSale(SQLObject):
> player = ForeignKey("Player", alternateID=True)
> askingprice = IntCol()
>
> Anyway I'm trying to do .select to get some data, but I can't seem to make
> comparisons properly.
> Some examples:
>
> >>> list(PlayerForSale.select(AND(PlayerForSale.q.player_id == Player.q.id,
> Player.q.passing > 1)))
> Traceback (most recent call last):
> File "<console>", line 1, in ?
> File
> "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1675-py2.4.egg/sqlobject/sqlbuilder.py",
> line
> 350, in __getattr__
> raise AttributeError("%s instance has no attribute '%s'" %
> (self.soClass.__name__, attr))
> AttributeError: PlayerForSale instance has no attribute 'player_id'
> >>> list(PlayerForSale.select(AND(PlayerForSale.q.player == Player.q.id,
> Player.q.passing > 1)))
> Traceback (most recent call last):
> File "<console>", line 1, in ?
> File
> "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1675-py2.4.egg/sqlobject/sqlbuilder.py",
> line
> 350, in __getattr__
> raise AttributeError("%s instance has no attribute '%s'" %
> (self.soClass.__name__, attr))
> AttributeError: PlayerForSale instance has no attribute 'player'
> >>>
>
>
> As you can see there are no PlayerForSale.q.* attributes for my ForeignKey,
> which is a real bummer.
> I can see this field in the database as well, so it's noting to do with that
>
> The closest I got was this:
>
> >>> len(list(Player.select(AND(Player.q.passing >= 1, Player.forsale > 0))))
> 34
>
> But that's not even nearly close as:
>
> >>> len(list(PlayerForSale.select()))
> 13
>
> I think that's just plain way off
>
> Can anyone help me with this? I'm totally stumped and a bit disappointed :-/
>
> Cheers
>
> -Rob
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---