Hi
I'm using DAL outside of web2py with the following code:
import sys
sys.path.append('w:/web2py/library.zip')
from gluon import DAL
db =
DAL('mysql://root:98lkjdfa@asdf09/ic2',folder='w:/web2py/applications/InfoCenter/databases',
auto_import=True)
print db.tables
rows = db().select(db.auth_user.ALL)
for row in rows:
print row.first_name, row.last_name
result = db.auth_user.insert(first_name='Stephen', last_name='Jones')
print result
db.commit()
The definition of my auth_user table is:
auth_user = db.define_table(
auth.settings.table_user_name,
Field('first_name', length=128, default='', required=True),
Field('last_name', length=128, default='', required=True),
Field('email', length=128, unique=True, required=True),
Field('password', 'password', length=512,
readable=False, label='Password'),
Field('registration_key', length=512,
writable=False, readable=False, default=''),
Field('reset_password_key', length=512,
writable=False, readable=False, default=''),
Field('registration_id', length=512,
writable=False, readable=False, default=''),
Field('brillLogon', length=10, default='', label='Brill Logon'),
Field('technician', 'boolean', default=False))
auth_user.first_name.requires =
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_user.last_name.requires =
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_user.password.requires = [IS_STRONG(), CRYPT()]
auth_user.email.requires = [IS_EMAIL(error_message=auth.messages.invalid_email),
IS_NOT_IN_DB(db, auth_user.email),
IS_NOT_EMPTY(error_message=auth.messages.is_empty)]
auth.settings.table_user = auth_user
I'm confused because it is allowing me to insert a row without and email even
though I'm telling it that email should not be empty and that it is required.
What am I missing?
-Jim