Massimo,

Thanks for your reply.

I used to define a custom auth_user table the following way:

auth.settings.table_user=db.define_table('auth_user',
    Field(....))

Are there any disadvantages to doing it this way?



You cannot do:
>
> IS_NOT_IN_DB(db,'custom_auth_table.shortname',...
>
> custom_auth_table is not the table name, it is a variable. Try
>
> IS_NOT_IN_DB(db,'auth_user.shortname',....
>
>
Problem solved!


Kind regards,

Annet 

> You have the same problem in many places.
>
>
>
> On Wednesday, 12 September 2012 03:46:06 UTC-5, Annet wrote:
>>
>> I defined a custom auth_user table:
>>
>> db.define_table(
>>     auth.settings.table_user_name,
>>     Field('title',length=8,requires=IS_IN_SET(['de 
>> heer','mevrouw'],zero=T('Select a value')),label='Aanheft * '),
>>     
>> Field('firstName',length=32,requires=IS_LENGTH(32,error_message=T('length 
>> exceeds 32 characters')),label='Voornaam'),
>>     
>> Field('lastName',length=64,default='',requires=[IS_LENGTH(64,error_message=T('length
>>  
>> exceeds 64 charactrer')),IS_NOT_EMPTY()],notnull=True,label='Achternaam * 
>> '),
>>     
>> Field('shortname',default='',requires=[IS_LENGTH(128,error_message=T('length 
>> exceeds 128 
>> characters')),IS_EMPTY_OR(IS_NOT_IN_DB(db,'custom_auth_table.shortname',error_message=T('shortname
>>  
>> already in database')))],notnull=True,unique=True),
>>     Field('phone',length=16,requires=IS_LENGTH(16,error_message='length 
>> exceeds 16 characters'),label='Telefoon'),
>>     
>> Field('email',length=128,default='',requires=[IS_LENGTH(128,error_message=T('length
>>  
>> exceeds 128 characters')),IS_EMAIL(error_message=T('invalid 
>> email')),IS_NOT_IN_DB(db,'custom_auth_table.email',error_message=T('email 
>> already in database'))],notnull=True,unique=True,label='E-mail * '),
>>     
>> Field('username',length=32,default='',requires=[IS_LENGTH(32,error_message=T('length
>>  
>> exceeds 32 
>> charactrer')),IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'custom_auth_table.username',error_message=T('username
>>  
>> already in 
>> database'))],notnull=True,unique=True,writable=False,readable=False,label='Gebruikersnaam
>>  
>> * '),
>>     Field('password', 
>> type='password',length=512,requires=[IS_STRONG(),CRYPT()],readable=False,label='Wachtwoord
>>  
>> * '),
>>     Field('nodeID','reference node',default='',requires=[IS_IN_DB(db,'
>> node.id','%(id)s',zero=T('Select a 
>> value'))],ondelete='CASCADE',notnull=True,label='NodeID * 
>> ',writable=False,readable=False),
>>     
>> Field('comment',type='text',requires=IS_LENGTH(512,error_message=T('length 
>> exceeds 512 characters'))),
>>     
>> Field('registration_key',length=512,default='',writable=False,readable=False),
>>     
>> Field('reset_password_key',length=512,default='',writable=False,readable=False),
>>     
>> Field('registration_id',length=512,default='',writable=False,readable=False),
>>     Field('createdOn',type='datetime',default=request.now),
>>     
>> Field('modifiedOn',type='datetime',default=request.now,update=request.now))
>>
>> ## get the custom_auth_table
>> custom_auth_table = db[auth.settings.table_user_name]
>> ## tell auth to use custom_auth_table
>>  auth.settings.table_user = custom_auth_table
>> ## to prevent the auth_cas table from being created
>> auth.settings.cas_domains = None
>> ## create all tables needed by auth if not custom tables
>> auth.define_tables(migrate=True,username=True,signature=False)
>>
>>
>>
>> When I enter a user I get the following error:
>>
>>
>> Traceback (most recent call last):
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/restricted.py", line 
>> 209, in restricted
>>     exec ccode in environment
>>   File 
>> "/Library/Python/2.6/site-packages/web2py/applications/init/controllers/appadmin.py"
>>  <http://127.0.0.1:8000/admin/default/edit/init/controllers/appadmin.py>, 
>> line 444, in <module>
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/globals.py", line 
>> 185, in <lambda>
>>     self._caller = lambda f: f()
>>   File 
>> "/Library/Python/2.6/site-packages/web2py/applications/init/controllers/appadmin.py"
>>  <http://127.0.0.1:8000/admin/default/edit/init/controllers/appadmin.py>, 
>> line 129, in insert
>>     if form.accepts(request.vars, session):
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/sqlhtml.py", line 
>> 1223, in accepts
>>     hideerror=hideerror,
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 1952, 
>> in accepts
>>     status = self._traverse(status,hideerror)
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, 
>> in _traverse
>>     newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, 
>> in _traverse
>>     newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, 
>> in _traverse
>>     newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, 
>> in _traverse
>>     newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 827, 
>> in _traverse
>>     newstatus = self._validate()
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 1706, 
>> in _validate
>>     (value, errors) = validator(value)
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/validators.py", line 
>> 2505, in __call__
>>     return self.other(value)
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/validators.py", line 
>> 558, in __call__
>>     table = self.dbset.db[tablename]
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/dal.py", line 7136, 
>> in __getitem__
>>     return self.__getattr__(str(key))
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/dal.py", line 7143, 
>> in __getattr__
>>     return ogetattr(self, key)
>> AttributeError: 'DAL' object has no attribute 'custom_auth_table'
>>
>>
>>
>> What's wrong with this way of defining a custom auth_user table?
>>
>>
>> Annet
>>
>

-- 



Reply via email to