Hi,

I'm currently working on a project that in its model has the standard
TG User table, and a table of my own, Task. The idea is that each user
has a task list, and a task can have multiple Users associated with it.

At the moment my model.py looks something like this:

class Task(SQLObject):
    name = UnicodeCol()
    users = RelatedJoin('User', joinColumn='user', otherColumn='task',
intermediateTable='user_tasks')

class User(SQLObject):
    ...
    tasks = RelatedJoin('Task', joinColumn='task', otherColumn='user',
intermediateTable='user_tasks')


Now, I want to be able to assign each Task a priority, but I want two
Users to be able to prioritise a Task differently. To me, this would
mean putting an extra column in the user_tasks table to hold the
priority for each user/task pair, so I wrote:

class UserTasks(SQLObject):
    user = ForeignKey('User')
    task = ForeignKey('Task')
    priority = FloatCol()

I then ran 'tg-admin sql create', and it didn't throw up any errors,
but when I inspected the sqlite database, the extra priority field
wasn't included!

sqlite> .tables
group_permission  tg_group          user_tasks
permission        tg_user           visit
task              user_group        visit_identity

sqlite> .schema user_tasks
CREATE TABLE user_tasks (
user INT NOT NULL,
task INT NOT NULL
);


Presumably SQLObject creates the custom joining table first, then it
gets overwritten with the new auto-generated version?

Catwalk also chokes on the table when I click on its name so I'm having
difficulty working out what's going wrong:

2006-11-16 14:11:31,738 turbogears.controllers DEBUG Calling <function
index at 0xa744b1b4> with *((<turbogears.toolbox.ca twalk.browse.Browse
object at 0xa74a18ec>, u'UserTasks')), ** ({'start': 0, 'page_size':
10, 'context': '', 'filters': ''})
16/Nov/2006:14:11:31 HTTP INFO Page handler: <bound method Br
owse.index of <turbogears.toolbox.catwalk.browse.Browse objec t at
0xa74a18ec>>
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4
.egg/cherrypy/_cphttptools.py", line 105, in _run
    self.main()
  File "/usr/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4
.egg/cherrypy/_cphttptools.py", line 254, in main
    body = page_handler(*virtual_path, **self.params)
  File "<string>", line 3, in index
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a9-py2
.4.egg/turbogears/controllers.py", line 331, in expose
    output = database.run_with_transaction(
  File "<string>", line 5, in run_with_transaction
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a9-py2
.4.egg/turbogears/database.py", line 245, in so_rwt
    retval = func(*args, **kw)
  File "<string>", line 5, in _expose
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a9-py2
.4.egg/turbogears/controllers.py", line 348, in <lambda>
    mapping, fragment, *args, **kw)))
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a9-py2
.4.egg/turbogears/controllers.py", line 372, in _execute_func
    output = errorhandling.try_call(func, *args, **kw)
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a9-py2
.4.egg/turbogears/errorhandling.py", line 71, in try_call
    return func(self, *args, **kw)
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a9-py2
.4.egg/turbogears/toolbox/catwalk/browse.py", line 24, in ind ex
    total,rows = self.rows_for_model(object_name,start,page_s
ize,filters)
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a9-py2
.4.egg/turbogears/toolbox/catwalk/browse.py", line 121, in ro
ws_for_model
    for result in results:
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r
1860-py2.4.egg/sqlobject/sresults.py", line 155, in __iter__
    return iter(list(self.lazyIter()))
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r
1860-py2.4.egg/sqlobject/sresults.py", line 163, in lazyIter
    return conn.iterSelect(self)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r
1860-py2.4.egg/sqlobject/dbconnection.py", line 364, in iterS elect
    select, keepConnection=False)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r
1860-py2.4.egg/sqlobject/dbconnection.py", line 704, in __ini t__
    self.dbconn._executeRetry(self.rawconn, self.cursor, self .query)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r
1860-py2.4.egg/sqlobject/dbconnection.py", line 298, in _exec uteRetry
    return cursor.execute(query)
  File "/usr/lib/python2.4/site-packages/sqlite/main.py", lin e 244, in
execute
    self.rs = self.con.db.execute(SQL)
DatabaseError: no such column: user_tasks.id


Any help here would be great; I really need that priority column for
this project!

Thanks,

Nick Murdoch


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to