Thank you so much, that solved it. (It might be helpful to others if that important caveat makes it into the relevant section of documentation<http://www.web2py.com/books/default/chapter/29/09#Renaming-Auth-tables> at some point, though I know that not every detail can be explained succinctly there.)
On Sunday, April 7, 2013 7:29:00 PM UTC-5, Anthony wrote: > > Looks like by default, auth.signature gets defined when Auth is > initialized, which is before you have set the custom table names. To avoid > this do: > > auth = Auth(db, signature=False) > > In that case, auth.signature will instead be defined when you call > auth.define_tables(), by which point the custom tables names will already > be set. > > Anthony > > On Sunday, April 7, 2013 6:58:09 PM UTC-4, Jason Phillips wrote: >> >> When I follow what I thought to be standard practice (following this >> documentation<http://www.web2py.com/books/default/chapter/29/09#Renaming-Auth-tables>) >> >> for using alternative names for the auth tables, I'm seeing an incorrect >> foreign key reference on any subsequent table defined that uses >> auth.signature. >> >> Here's the basic test code in a db.py: >> >> auth = Auth(db) >> >> auth.settings.table_user_name = 'cst_user' >> auth.settings.table_group_name = 'cst_group' >> auth.settings.table_membership_name = 'cst_membership' >> auth.settings.table_permission_name = 'cst_permission' >> auth.settings.table_event_name = 'cst_event' >> auth.settings.table_cas_name = 'cst_cas' >> >> auth.define_tables(username=True,signature=False) >> >> db.define_table('tmp_mytable', >> Field('something'), >> auth.signature) >> >> >> >> This works so far as the auth tables are concerned; web2py creates them >> with the alternate names specified, properly referencing each other. >> >> However, the query generated to create the subsequent table that uses >> auth.signature (*tmp_mytable* above) refers in its foreign key >> declaration to the standard auth table names instead. The query below was >> generated (using SQLITE to test, though I first encountered this with >> Oracle). >> >> >> CREATE TABLE mytable( >> id INTEGER PRIMARY KEY AUTOINCREMENT, >> something CHAR(512), >> is_active CHAR(1), >> created_on TIMESTAMP, >> created_by INTEGER REFERENCES auth_user (id) ON DELETE CASCADE, >> modified_on TIMESTAMP, >> modified_by INTEGER REFERENCES auth_user (id) ON DELETE CASCADE >> ); >> >> Note that it has reverted to the default name "auth_user" for the >> referenced foreign keys. What am I doing wrong here? >> >> (Version 2.4.5-stable+timestamp.2013.04.06.10.09.56) >> > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.