I my model I defined my own auth_user table:

from gluon.tools import *
auth=Auth(globals(),db)
auth_table=db.define_table(auth.settings.table_user_name,
    Field('bedrijf', db.bedrijf, default='',
notnull=True,ondelete='CASCADE'),
    Field('first_name', length=128, default='', notnull=True),
    Field('last_name', length=128, default='', notnull=True),
    Field('email', length=128, default='', notnull=True),
    Field('site', type='boolean', default=False, notnull=True),
    Field('username', length=128, default='', notnull=True,
unique=True),
    Field('password', type='password', length=256, readable=False,
default='', notnull=True),
    Field('created_on',type='datetime'),
    Field('modified_on',type='datetime'),
    Field('most_recent_login',type='datetime'),
    Field('registration_key', length=128, writable=False,
readable=False, default=''))

auth_table.username.requires= IS_NOT_IN_DB(db, 'auth_table.username')
auth.settings.table_user=auth_table
auth.define_tables()
auth.settings.registration_requires_approval = True

The table are defined without problems. However, when I expose the
register function, which
I defined in a controller called: authentication.py,

def user():
    return dict(form=auth())

... and try to register a user I get the following error:

Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/web2py/gluon/restricted.py",
line 184, in restricted
    exec ccode in environment
  File "/Library/Python/2.5/site-packages/web2py/applications/cms/
controllers/authentication.py", line 9, in <module>
  File "/Library/Python/2.5/site-packages/web2py/gluon/globals.py",
line 103, in <lambda>
    self._caller = lambda f: f()
  File "/Library/Python/2.5/site-packages/web2py/applications/cms/
controllers/authentication.py", line 7, in user
    return dict(form=auth())
  File "/Library/Python/2.5/site-packages/web2py/gluon/tools.py", line
686, in __call__
    return self.register()
  File "/Library/Python/2.5/site-packages/web2py/gluon/tools.py", line
1136, in register
    onvalidation=onvalidation):
  File "/Library/Python/2.5/site-packages/web2py/gluon/sqlhtml.py",
line 765, in accepts
    onvalidation,
  File "/Library/Python/2.5/site-packages/web2py/gluon/html.py", line
1269, in accepts
    status = self._traverse(status)
  File "/Library/Python/2.5/site-packages/web2py/gluon/html.py", line
453, in _traverse
    newstatus = c._traverse(status) and newstatus
  File "/Library/Python/2.5/site-packages/web2py/gluon/html.py", line
453, in _traverse
    newstatus = c._traverse(status) and newstatus
  File "/Library/Python/2.5/site-packages/web2py/gluon/html.py", line
453, in _traverse
    newstatus = c._traverse(status) and newstatus
  File "/Library/Python/2.5/site-packages/web2py/gluon/html.py", line
453, in _traverse
    newstatus = c._traverse(status) and newstatus
  File "/Library/Python/2.5/site-packages/web2py/gluon/html.py", line
460, in _traverse
    newstatus = self._validate()
  File "/Library/Python/2.5/site-packages/web2py/gluon/html.py", line
1078, in _validate
    (value, errors) = validator(value)
  File "/Library/Python/2.5/site-packages/web2py/gluon/validators.py",
line 400, in __call__
    field = self.dbset._db[tablename][fieldname]
  File "/Library/Python/2.5/site-packages/web2py/gluon/sql.py", line
1214, in __getitem__
    return dict.__getitem__(self, str(key))
KeyError: 'auth_table'


When I try to register a user via the appadmin interface I get the
same error. When I adjust the table definition:

auth.settings.table_user=db.define_table('auth_user',
    Field('bedrijf', db.bedrijf, default='',
notnull=True,ondelete='CASCADE'),
    Field('first_name', length=128, default='', notnull=True),
    Field('last_name', length=128, default='', notnull=True),
    Field('email', length=128, default='', notnull=True),
    Field('site', type='boolean', default=False, notnull=True),
    Field('username', length=128, default='', notnull=True,
unique=True),
    Field('password', type='password', length=256, readable=False,
default='', notnull=True),
    Field('created_on',type='datetime'),
    Field('modified_on',type='datetime'),
    Field('most_recent_login',type='datetime'),
    Field('registration_key', length=128, writable=False,
readable=False, default=''))

db.auth_user.bedrijf.requires=IS_IN_DB(db, db.bedrijf.id, '%
(bedrijfsnaam)s')
db.auth_user.bedrijf.label='Bedrijf * '
db.auth_user.first_name.requires=[IS_LENGTH(128,error_message='lengte
overschreidt 128 tekens'), IS_NOT_EMPTY()]
db.auth_user.first_name.label='Voornaam * '
db.auth_user.last_name.requires=[IS_LENGTH(128,error_message='lengte
overschreidt 128 tekens'), IS_NOT_EMPTY()]
db.auth_user.last_name.label='Achternaam * '
db.auth_user.email.requires=[IS_LENGTH(128,error_message='lengte
overschreidt 128 tekens'), IS_EMAIL(), IS_NOT_EMPTY()]
db.auth_user.email.label='E-mail * '
db.auth_user.site.requires=IS_NOT_EMPTY()
db.auth_user.site.default=False
db.auth_user.site.readable=False
db.auth_user.site.writable=False
db.auth_user.username.requires=[IS_LENGTH(128,error_message='lengte
overschreidt 128 tekens'), IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
'auth_user.username')]
db.auth_user.username.label='Username * '
db.auth_user.password.requires=[IS_NOT_EMPTY(), CRYPT()]
db.auth_user.password.label='Password * '
db.auth_user.created_on.default=request.now
db.auth_user.created_on.readable=False
db.auth_user.created_on.writable=False
db.auth_user.modified_on.default=request.now
db.auth_user.modified_on.update=request.now
db.auth_user.modified_on.readable=False
db.auth_user.modified_on.writable=False
db.auth_user.most_recent_login.default=request.now
db.auth_user.most_recent_login.readable=False
db.auth_user.most_recent_login.writable=False
db.auth_user.registration_key.default=''
db.auth_user.registration_key.readable=False
db.auth_user.registration_key.writable=False


The problem is solved, however, my table definition no longer complies
with the one given in the book. I am working with Web2py version
1.72.3.


Kind regards,

Annet.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to