The actual code from the book:
db.define_table(
auth.settings.table_user_name,
Field <http://web2py.com/book/default/docstring/Field>('first_name',
length=128, default=''),
Field <http://web2py.com/book/default/docstring/Field>('last_name',
length=128, default=''),
Field <http://web2py.com/book/default/docstring/Field>('email', length=128,
default='', unique=True),
Field <http://web2py.com/book/default/docstring/Field>('password',
'password', length=512,
readable=False, label='Password'),
Field <http://web2py.com/book/default/docstring/Field>('registration_key',
length=512,
writable=False, readable=False, default=''),
Field
<http://web2py.com/book/default/docstring/Field>('reset_password_key',
length=512,
writable=False, readable=False, default=''),
Field <http://web2py.com/book/default/docstring/Field>('registration_id',
length=512,
writable=False, readable=False, default=''))
custom_auth_table = db[auth.settings.table_user_name] # get the
custom_auth_table
custom_auth_table.first_name.requires = \
IS_NOT_EMPTY
<http://web2py.com/book/default/docstring/IS_NOT_EMPTY>(error_message=auth.messages.is_empty)
custom_auth_table.last_name.requires = \
IS_NOT_EMPTY
<http://web2py.com/book/default/docstring/IS_NOT_EMPTY>(error_message=auth.messages.is_empty)
custom_auth_table.password.requires = [IS_STRONG
<http://web2py.com/book/default/docstring/IS_STRONG>(), CRYPT
<http://web2py.com/book/default/docstring/CRYPT>()]
custom_auth_table.email.requires = [
IS_EMAIL
<http://web2py.com/book/default/docstring/IS_EMAIL>(error_message=auth.messages.invalid_email),
IS_NOT_IN_DB <http://web2py.com/book/default/docstring/IS_NOT_IN_DB>(db,
custom_auth_table.email)]
auth.settings.table_user = custom_auth_table # tell auth to use
custom_auth_table
# before
# auth.define_tables()
You forgot this line which creates and assigns a reference to
custom_auth_table:
custom_auth_table = db[auth.settings.table_user_name] # get the
custom_auth_table