You can but I do not see why you would ever do it. I am sure there is
a better way to do what you are trying to do and perhaps you should
explain what you are trying to do. Anyayw, since this is what you are
doing there are some caveats.

auth.settings.table_user by default is called 'auth_user'

If you want to change the name it is not sufficient to say

auth.settings.table_user=db.define_table('my_auth_user',...)
you also must change auth.settings.table_user_name='my_auth_user'

Moreover there is an order in which tables are defined and you cannot
reference a table that has not yet been defined.

Massimo


On May 23, 10:42 pm, Hasanat Kazmi <[email protected]> wrote:
> I have two different objects for Auth
> autha = Auth(....)
> authb = Auth(....)
>
> Can we have multiple instances of Auth, if no then why not?
>
> On May 24, 4:03 am, mdipierro <[email protected]> wrote:
>
> > Can you post the entire code that gives the problem?
>
> > Do you have both authc and autht? There should be only one auth.
>
> > When delete a database make sure also delete everything in app/
> > databases/
>
> > Massimo
>
> > On May 23, 5:15 pm, Hasanat Kazmi <[email protected]> wrote:
>
> > > Now, I have changed database, I have switched to mysql, and whole
> > > database is empty. Now it gives me this error:
> > > Table 'web2py.teacher' doesn't exist
> > > If create table myself, it says it already exists. Any help?
>
> > > On May 23, 11:49 pm, Hasanat Kazmi <[email protected]> wrote:
>
> > > > Hi,
> > > > I am newbie to web2py. I am working on a project where multiple people
> > > > will have to get different type of authentication, (e.g. teacher and
> > > > student have different level of access to the system). Now the problem
> > > > is that I can not create different instances of Auth class, e.g.
>
> > > > autht = Auth(globals(), db)
> > > > autht.settings.table_user = db.define_table('teacher',
> > > >     db.Field('first_name'),
> > > >     db.Field('middlename'),
> > > >     db.Field('last_name'),
> > > >     db.Field('specialization'),
> > > >     db.Field('highestdegre'),
> > > >     db.Field('housenum'),
> > > >     db.Field('streetnum'),
> > > >     db.Field('area'),
> > > >     db.Field('city'),
> > > >     db.Field('country'),
> > > >     db.Field('phone'),
> > > >     db.Field('email',
> > > >         requires = [IS_EMAIL(),
> > > >                     IS_NOT_IN_DB(db,'teacher.email')]),
> > > >     db.Field('username'),
> > > >     db.Field('password', 'password', readable=False, requires=CRYPT
> > > > ()),
> > > >     db.Field('registration_key', length = 128, writable = False,
> > > > readable = False, default = ''),
> > > >     db.Field('createdon', 'date' , default = now),
> > > >     #db.Field('controller', db.controller)
> > > > )
> > > > autht.define_tables()
>
> > > > work seamlessly well but when I create another one, no matter which
> > > > one is defined first it throws error, e.g I created following:
>
> > > > authc = Auth(globals(), db)
> > > > authc.settings.table_user = db.define_table('controller',
> > > >     db.Field('first_name'),
> > > >     db.Field('middlename'),
> > > >     db.Field('last_name'),
> > > >     db.Field('phone'),
> > > >     db.Field('email',
> > > >         requires = [IS_EMAIL(),
> > > >                     IS_NOT_IN_DB(db,'teacher.email')]),
> > > >     db.Field('username'),
> > > >     db.Field('password', 'password', readable=False, requires=CRYPT
> > > > ()),
> > > >     db.Field('registration_key', length = 128, writable = False,
> > > > readable = False, default = ''),
> > > >     db.Field('createdon', 'date' , default = now)
> > > > )
> > > > authc.define_tables()
>
> > > > this gives me following error:
>
> > > > ProgrammingError: (1146, "Table 'web2py.controller' doesn't exist")
>
> > > > does this error mean that web2py didnt find controller table in db,
> > > > isnt it supposed to make it itself?
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to