I am trying to use a postgresql database, but it seems that due to it's
awareness of dependancies tables need to be created in a specific
order. on tg-admin sql create I am simply getting the error
> psycopg2.ProgrammingError: Relation "tg_user" does not exist
Because I am joining the tg_user from one of my own tables. After some
searching I understand it is possible to get SQLObject to specify the
order with something like soClasses or _so_classes but that's the limit
of my knowledge so far.
Has anyone else had this problem or know how to specify the order?
Are you using separate model files? If it was just one file, the order should
be built correctly for you...
Anyway, you have to specify _so_classes as a list (I'm saying from the docs,
I've chosen to avoid this by using just one model file) so I believe it would
be something like:
_so_classes = ['class1', 'TG_User', 'class2', ...]
(I do a join on a table of mine that is tied to TG_User on a 1:1 basis. This
table has more fields and is declared inside my model.py, so I didn't find
that problem.)
--
Jorge Godoy <jgo...@gmail.com>
The interesting thing is the only table that gets created is the
*last* one in model.py
I did look for docs but I couldn't find anything, now I know it's
_so_classes I'll have another look.
lazy question then: Where would I put that just at the start of
model.py? and can I do a partial list or do I have to specify every
class?
> lazy question then: Where would I put that just at the start of
> model.py? and can I do a partial list or do I have to specify every
> class?
I'd put it at the beginning and write a full list... But as I said, I've
never used that :-(
--
Jorge Godoy <jgo...@gmail.com>
...
__connection__ = hub
soClasses = ['TG_User', 'TG_Group', 'TG_Permission', 'MyTable']
And it worked fine cheers Jorge
hehe yes!
When I do tg-admin sql list it displays my own classes first:
myapp.model.MyTables
...
turbogears.identity.soprovider.TG_Group
turbogears.identity.soprovider.TG_Permission
turbogears.identity.soprovider.TG_User
turbogears.identity.soprovider.TG_VisitIdentity
so that is clearly the order it wants to create them. I don't know
about TG_VisitIdentity though, I included that in the soClasses list
and it said it didn't exist!
I had a similar problem with PostgreSQL where I had a table that was a
manual many-to-many relation (I needed to add attributes to this
relation). I suspect it broke whatever dependency tracking SQLObject
has and this helped me solve that problem.
Baruch