[TurboGears] Re: Problem with SO and .select() when comparing joined data

2006-04-24 Thread Robin Haswell

Tim Lesher wrote:
 On 4/23/06, Robin Haswell [EMAIL PROTECTED] wrote:
 AttributeError: PlayerForSale instance has no attribute 'player'
 
 This looks a lot like Trac ticket #279, which I believe is a bug that
 was introduced in SQLObject 0.7:
 
 http://trac.turbogears.org/turbogears/ticket/279
 
 The workaround can be found at:
 
 http://joe.sl4g.com/words/code/sqlobject_order.html
 

No it's not a problem with creating tables:

mysql show create table player_for_sale;
+-++
| Table   | Create Table 
 
  |
+-++
| player_for_sale | CREATE TABLE `player_for_sale` (
   `id` int(11) NOT NULL auto_increment,
   `player_id` int(11) default NULL,
   `askingprice` int(11) default NULL,
   PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-++
1 row in set (0.00 sec)

mysql

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---



[TurboGears] Re: Problem with SO and .select() when comparing joined data

2006-04-24 Thread Robin Haswell

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 turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---



[TurboGears] Re: Problem with SO and .select() when comparing joined data

2006-04-23 Thread Robin Haswell

BTW it's late here and I should have made it a bit clearer:

What I'm actually trying to do is get a list of PlayerForSale objects based on 
the SingleJoin'd 
.player's attributes.

The SQL for this would be:

select * from player_for_sale, player where player_for_sale.player_id = 
player.id and 
player.passing = 1


However I'd really like to use SO for this as I want to build my search 
criteria pythonicly,

Cheers

-Rob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---