I defined the following 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_EMPTY(),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,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(username=True, signature=False)
When I save the file, the 'Last saved on' field colors yellow and the line:
custom_auth_table = db[auth.settings.table_user_name]
... becomes gray. When I go to 'edit application init' and click the
'database administration' button I get the following error:
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/web2py/gluon/restricted.py", line
208, in restricted
ccode = compile2(code,layer)
File "/Library/Python/2.6/site-packages/web2py/gluon/restricted.py", line
193, in compile2
return compile(code.rstrip().replace('\r\n','\n')+'\n', layer, 'exec')
File
"/Library/Python/2.6/site-packages/web2py/applications/init/models/20_auth_db.py"
<http://127.0.0.1:8000/admin/default/edit/init/models/20_auth_db.py>, line 36
custom_auth_table = db[auth.settings.table_user_name]
^
SyntaxError: invalid syntax
Error snapshot [image: help]
<type 'exceptions.SyntaxError'>(invalid syntax (20_auth_db.py, line 36))
inspect attributes
Frames
-
*File /Library/Python/2.6/site-packages/web2py/gluon/restricted.py in
restricted at line 208* code arguments variables
-
*File /Library/Python/2.6/site-packages/web2py/gluon/restricted.py in
compile2 at line 193* code arguments variables
Function argument list
(code="# -*- coding: utf-8
-*-\n\n#######################...use_janrain(auth,filename='private/janrain.key')\n",
layer='/Library/Python/2.6/site-packages/web2py/applications/init/models/20_auth_db.py')
Code listing
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
def compile2(code,layer):
"""
The +'\n' is necessary else compile fails when code ends in a comment.
"""
return compile(code.rstrip().replace('\r\n','\n')+'\n', layer, 'exec')
def restricted(code, environment=None, layer='Unknown'):
"""
runs code in environment and returns the output. if an exception occurs
Variables builtincompile <built-in function compile> code "# -*-
coding: utf-8
-*-\n\n#######################...use_janrain(auth,filename='private/janrain.key')\n"
code.rstrip <built-in method rstrip of str object at 0x2382800>
).replace undefined layer
'/Library/Python/2.6/site-packages/web2py/applications/init/models/20_auth_db.py'
I don't need to use OpenID, Facebook etc. so I commented out:
## from gluon.contrib.login_methods.rpx_account import use_janrain
## use_janrain(auth,filename='private/janrain.key')
... is that's what's causing the problem?
Kind regards,
Annet.
--