#701: catwalk.Browse.join_foreign_key makes bad SQLObject column name from
joinColumn
-------------------------------------+--------------------------------------
 Reporter:  [EMAIL PROTECTED]  |        Owner:  anonymous
     Type:  defect                   |       Status:  new      
 Priority:  high                     |    Milestone:  1.1      
Component:  Toolbox.Catwalk          |      Version:  0.9a4    
 Severity:  major                    |   Resolution:           
 Keywords:                           |  
-------------------------------------+--------------------------------------
Comment (by Joost):

 The catwalk code could be improved by using the same syntax as used in
 sqlobject.joins:
 {{{
 foreign_key =
 column.soClass.sqlmeta.style.dbColumnToPythonAttr(column.joinColumn)
 }}}

 However, SQLObject is self seems to be broken when it comes to naming.
 E.g:
 {{{
 >>> from sqlobject import *
 >>> from turbogears.database import AutoConnectHub
 >>> hub = AutoConnectHub()
 >>> __connection__ = hub
 >>> class Pet(SQLObject):
 ...     class sqlmeta:
 ...         table = 'tg_pet'
 ...     name = StringCol()
 ...     user = ForeignKey("User")
 ...
 >>> class User(SQLObject):
 ...     class sqlmeta:
 ...         table = "tg_user"
 ...     name = StringCol()
 ...     my_pet = SingleJoin("Pet")
 ...
 >>> from turbogears import database
 >>> database.set_db_uri("sqlite:///:memory:")
 >>> User.createTable(ifNotExists=True)
 >>> Pet.createTable(ifNotExists=True)
 >>> u = User(name="jhon")
 >>> u.my_pet
 Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "<string>", line 1, in <lambda>
   File "c:\python24\lib\site-
 packages\SQLObject-0.7.2-py2.4.egg\sqlobject\joins.py", line 293, in
 performJoin
     results = self.otherClass.select(
   File "c:\python24\lib\site-
 packages\SQLObject-0.7.2-py2.4.egg\sqlobject\sqlbuilder.py", line 374, in
 __getattr__
     raise AttributeError("%s instance has no attribute '%s'" %
 (self.soClass.__name__, attr))
 AttributeError: Pet instance has no attribute 'tgUserID'
 }}}

-- 
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/701>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears Tickets" 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-tickets?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to