Hi,

still got my problems with SQLObject :(

I still can't query for RelatedJoin fields:

class Todo(SQLObject):
    created = DateTimeCol( default=datetime.now )
    completed = DateTimeCol( default=None )
     ....
    users = RelatedJoin("User", intermediateTable="todo_user",
                        joinColumn="todo_id", otherColumn="user_id")

class User(SQLObject):
    class sqlmeta:
        table = 'tg_user'

    user_name = UnicodeCol(length=16, alternateID=True,
                           alternateMethodName='by_user_name')
    email_address = UnicodeCol(length=255, alternateID=True,
                               alternateMethodName='by_email_address')
    ...
    todos = RelatedJoin("Todo", intermediateTable="todo_user",
                        joinColumn="user_id", otherColumn="todo_id")

Now, I am trying to get all Todos from a specific User:

        u = User.get(1)
        todos = Todo.select(Todo.q.users == u)

and get:

  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/SQLObject-0.9.2-py2

.4.egg/sqlobject/sqlbuilder.py", line 394, in __getattr__

    raise AttributeError("%s instance has no attribute '%s'" %
(self.soClass.__name__, attr))

AttributeError: Todo instance has no attribute 'users'


How am I supposed to get this Todos? Should I select() all and check the
users attribute by Hand?
And what is the deal with User.todos? It get's me my todos, but in as a
list, not a dictionary. That's not really usefull.


I'm really sorry for bugging you again, but I'm so fucking pissed! I've
wasted so much time with SQLObject, for trying to do very easy querys...
gonna do it in SQL next time.

Thanks a lot for trying to help!


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to