did you use the whole db.py default? something like this (in this example i also use the company table that is related with auth user table): *db.py* # -*- coding: utf-8 -*-
######################################################################### ## This scaffolding model makes your app work on Google App Engine too ## File is released under public domain and you can use without limitations ######################################################################### ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all']) else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore') ## store sessions and tickets there session.connect(request, response, db=db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## from google.appengine.api.memcache import Client ## session.connect(request, response, db = MEMDB(Client())) ## by default give a view/generic.extension to all actions from localhost ## none otherwise. a pattern can be 'controller/function.extension' response.generic_patterns = ['*'] if request.is_local else [] ## (optional) optimize handling of static files # response.optimize_css = 'concat,minify,inline' # response.optimize_js = 'concat,minify,inline' ######################################################################### ## Here is sample code if you need for ## - email capabilities ## - authentication (registration, login, logout, ... ) ## - authorization (role based authorization) ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss) ## - old style crud actions ## (more options discussed in gluon/tools.py) ######################################################################### from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db) crud, service, plugins = Crud(db), Service(), PluginManager() # append fields : auth.signature db._common_fields.append(auth.signature) # create table : company db.define_table('company', Field('company_name'), Field('website'), format='%(company_name)s') # create index : company db.executesql('CREATE INDEX IF NOT EXISTS idx_company ON company (id, company_name);') # create table : company archive db.define_table('company_archive', db.company, Field('current_record', 'reference company')) # custom auth user table auth.settings.extra_fields['auth_user']=[ Field('gender', 'list:string'), Field('address', 'text'), Field('zip'), Field('city'), Field('country'), Field('phone'), Field('company', 'reference company')] ## create all tables needed by auth if not custom tables auth.define_tables(username=False, signature=True) ## configure email mail = auth.settings.mailer mail.settings.server = 'logging' or 'smtp.gmail.com:587' mail.settings.sender = 'y...@gmail.com' mail.settings.login = 'username:password' ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc. ## register with janrain.com, write your domain:api_key in private/janrain.key from gluon.contrib.login_methods.rpx_account import use_janrain use_janrain(auth, filename='private/janrain.key') ######################################################################### ## Define your tables below (or better in another model file) for example ## ## >>> db.define_table('mytable',Field('myfield','string')) ## ## Fields can be 'string','text','password','integer','double','boolean' ## 'date','time','datetime','blob','upload', 'reference TABLENAME' ## There is an implicit 'id integer autoincrement' field ## Consult manual for more options, validators, etc. ## ## More API examples for controllers: ## ## >>> db.mytable.insert(myfield='value') ## >>> rows=db(db.mytable.myfield=='value').select(db.mytable.ALL) ## >>> for row in rows: print row.id, row.myfield ######################################################################### ## after defining tables, uncomment below to enable auditing # auth.enable_record_versioning(db) # auth_user custom_auth_table=db[auth.settings.table_user_name] custom_auth_table.gender.label=T('Gender') custom_auth_table.address.label=T('Address') custom_auth_table.zip.label=T('Zip') custom_auth_table.city.label=T('City') custom_auth_table.country.label=T('Country') custom_auth_table.phone.label=T('Phone') custom_auth_table.company.label=T('Company') auth.settings.table_user = custom_auth_table # company db.company.company_name.label=T('Company Name') db.company.website.label=T('Website') from gluon.contrib.populate import populate if db(db.auth_user).isempty(): # company db.company.insert(company_name = 'svc shop', website = 'http://stifix.com') # group auth.add_group('Manager', 'Manager') auth.add_group('Admin', 'Admin') # membership auth.add_membership('1', '1') auth.add_membership('2', '1') auth.add_membership('2', '2') # user db.auth_user.bulk_insert([{'first_name' : 'Manager', 'last_name' : 'Manager', 'email' : 'mana...@stifix.com', 'password' : db.auth_user.password.validate('password')[0], 'gender' : 'Male', 'address' : 'Address', 'zip' : '11111', 'city' : 'Jakarta', 'country' : 'Indonesia', 'phone' : '1', 'company' : 1}, {'first_name' : 'Admin', 'last_name' : 'Admin', 'email' : 'ad...@stifix.com', 'password' : db.auth_user.password.validate('password')[0], 'gender' : 'Male', 'address' : 'Address', 'zip' : '11111', 'city' : 'Jakarta', 'country' : 'Indonesia', 'phone' : '2', 'company' : 1}]) # auth_user custom_auth_table=db[auth.settings.table_user_name] custom_auth_table.gender.required=True custom_auth_table.address.required=True custom_auth_table.zip.required=True custom_auth_table.city.required=True custom_auth_table.country.required=True custom_auth_table.phone.required=True custom_auth_table.company.required=True auth.settings.table_user = custom_auth_table # company db.company.company_name.required=True db.company.website.required=True # auth_user custom_auth_table=db[auth.settings.table_user_name] custom_auth_table.gender.requires=IS_IN_SET(['Male', 'Female']) custom_auth_table.address.requires=IS_NOT_EMPTY() custom_auth_table.zip.requires=IS_MATCH('^\d{5,5}$', error_message='not a zip code') custom_auth_table.city.requires=IS_NOT_EMPTY() custom_auth_table.country.requires=IS_NOT_EMPTY() custom_auth_table.phone.requires=IS_NOT_IN_DB(db, custom_auth_table.phone) custom_auth_table.company.requires=IS_IN_DB(db, db.company.id, '%(company_name)s') auth.settings.table_user=custom_auth_table # company db.company.company_name.requires=IS_NOT_IN_DB(db, 'company.company_name') db.company.website.requires=[IS_URL(), IS_NOT_IN_DB(db, 'company.website')] > > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.