PostgreSQL and dependancies

1 view
Skip to first unread message

Richard (koorb)

unread,
Mar 15, 2006, 7:48:14 AM3/15/06
to TurboGears
Afternoon everyone,

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?

Jorge Godoy

unread,
Mar 15, 2006, 8:04:41 AM3/15/06
to turbo...@googlegroups.com
"Richard (koorb)" <richard.s...@googlemail.com> writes:

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>

Richard (koorb)

unread,
Mar 15, 2006, 8:48:27 AM3/15/06
to TurboGears
Other than the external soprovider which is imported at the top of the
model.py I only have one file at the moment.

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?

Jorge Godoy

unread,
Mar 15, 2006, 8:55:22 AM3/15/06
to turbo...@googlegroups.com
"Richard (koorb)" <richard.s...@googlemail.com> writes:

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

Jorge Vargas

unread,
Mar 15, 2006, 8:57:34 AM3/15/06
to turbo...@googlegroups.com
you did uncomment the
from turbogears.identity.soprovider import TG_User, TG_Group, TG_Permission
line right?

Richard (koorb)

unread,
Mar 15, 2006, 9:11:06 AM3/15/06
to TurboGears
ah ha! that worked, only it was soClasses so in model.py I did:

...
__connection__ = hub
soClasses = ['TG_User', 'TG_Group', 'TG_Permission', 'MyTable']

And it worked fine cheers Jorge

Richard (koorb)

unread,
Mar 15, 2006, 9:15:20 AM3/15/06
to TurboGears
Jorge Vargas wrote:
> you did uncomment the
> from turbogears.identity.soprovider import TG_User, TG_Group, TG_Permission
> line right?

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!

Jorge Vargas

unread,
Mar 15, 2006, 9:22:58 AM3/15/06
to turbo...@googlegroups.com
so have to config some stuff on config.py for visit tracking to work

On 3/15/06, Richard (koorb) < richard.s...@googlemail.com> wrote:

baruch

unread,
Mar 15, 2006, 10:43:04 AM3/15/06
to TurboGears
Thanks!

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

Reply all
Reply to author
Forward
0 new messages