A minor problem:
auth.define_tables() # creates all needed tables
should go after
auth_table= db.define_table(auth.settings.table_user_name, ....)
Massimo
On Jul 25, 9:04 am, zenghua <[email protected]> wrote:
> Hi,everyone:
> I am a new to web2py,today,I type these code in my "db.py" :
>
> -----------
> from gluon.tools import *
> auth=Auth(globals(),db) # authentication/authorization
> auth.define_tables() # creates all needed tables
> crud=Crud(globals(),db) # for CRUD helpers using auth
> service=Service(globals()) # for json, xml, jsonrpc, xmlrpc, amfrpc
>
> auth_table= db.define_table(auth.settings.table_user_name,
> Field('name',length=128,default='',label='用户名',requires=IS_NOT_EMPTY
> (error_message="用户名不能为空")),
> Field('email',length=128,default='',label='EMAIL',requires=[IS_EMAIL(error_message
> ='不合法的地址'),
> IS_NOT_IN_DB(db,'%s.email'%auth.settings.table_user_name)]),
> Field('password','password',readable=False,label='密码',requires=CRYPT()),
> Field('registration_key',length=128,default='',writable=False,readable=False))
> auth_table = auth.settings.table_user
> ----------
> when I run it and check my label,it show me some error:
>
> Error traceback
>
> Traceback (most recent call last):
> File "gluon/restricted.py", line 176, in restricted
> File
> "D:/book/python/web2py/web2py1.65/applications/myblog2/models/db.py",
> line 41, in <module>
> File "gluon/sql.py", line 992, in define_table
> SyntaxError: invalid table name: auth_user
>
> the error line(41):
> Field('registration_key',length=128,default='',writable=False,readable=False))
>
> something mistake I've done?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" 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
-~----------~----~----~----~------~----~------~--~---