Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #595 (closed defect: worksforme)

Opened 13 years ago

Last modified 12 years ago

SOIdentityProvider should not always create classes

Reported by: ghaering Owned by: anonymous
Priority: normal Milestone: 0.9
Component: Identity Version:
Severity: blocker Keywords: soidentityprovider model table
Cc: jeff@…


I am using the SQLObject identity provider with custom model classes. So far, so good. But I don't let SQLObject create the database objects for me, because I want more control. The same for these model classes - I use PostgreSQL views on the database for them.

But, unfortunately, TG tries to create the tables for me on start, and even hangs because it cannot create them (a view under the same name of course already exists).

I propose to add a way to SQLObject identity provider to not make it create classes. Perhaps an attribute to the model classes that it honours.

Or perhaps the problem is a more general one and SQLObject should be taught to also look for views if it checks the "ifNotExists" condition.

The following local patch to TG is currently necessary so that I can continue with my work:

Index: /home/gerhard/src/turbogears/turbogears/identity/soprovider.py
--- /home/gerhard/src/turbogears/turbogears/identity/soprovider.py      (revision 793)
+++ /home/gerhard/src/turbogears/turbogears/identity/soprovider.py      (working copy)
@@ -162,9 +162,9 @@
         # create the database tables
-            user_class.createTable(ifNotExists=True)
-            group_class.createTable(ifNotExists=True)
-            permission_class.createTable(ifNotExists=True)
+            # user_class.createTable(ifNotExists=True)
+            # group_class.createTable(ifNotExists=True)
+            # permission_class.createTable(ifNotExists=True)

Change History

comment:1 Changed 13 years ago by ghaering

  • Cc jeff@… added

comment:2 Changed 13 years ago by Jeff Watkins

Actually, the goal is to have tg-admin call create_extension_model for all registered extensions when you call sql create. Unfortunately, since I don't know how to hack tg-admin, I can't really do that.

I would also agree that SQLObject should be smart enough to check for views as well as tables. But there are so many things SQLObject *should* do that it doesn't. And I've given up wishing.

comment:3 Changed 13 years ago by Jeff Watkins

See Ticket #601.

comment:4 Changed 13 years ago by ghaering

Actually SQLObject seems to do (almost) the right thing here (tableExists in pgconnection.py). It checks if there's an entry in pg_class with the requested table name. It would be smart if the check were case-insensitive, though.

I'll check later if the problem goes away by putting the table name with the currently required case in the TurboGears config file or model definition.

comment:5 Changed 13 years ago by ghaering

  • Status changed from new to closed
  • Resolution set to worksforme

The "solution" on PostgreSQL is to use lowercase table names. I used uppercase table names in sqlmeta.table and this won't work with PostgreSQL, because the SQLObject/PostgreSQL table lookup is case sensitive.

Closing as worksforme.

Note: See TracTickets for help on using tickets.