Hmmm... i never call auth.define_tables I guess because I wanted to customize the auth_user table. And yet the following tables all get created:
| auth_cas | | auth_cas_archive | | auth_event | | auth_event_archive | | auth_group | | auth_group_archive | | auth_membership | | auth_membership_archive | | auth_permission | | auth_permission_archive | | auth_user | | auth_user_archive Could that be why? On Saturday, September 8, 2012 1:51:24 PM UTC-4, Massimo Di Pierro wrote: > > works for me > > >>> db= DAL() > >>> from gluon.tools import Auth > >>> auth = Auth(db) > >>> auth.define_tables() > >>> db._common_fields.append(auth.signature) > >>> db.define_table('thing', > Field('name'), > Field('name2', > writable=False, > compute=lambda r: r.name+'xxx')) > >>> auth.enable_record_versioning(db) > >>> print db.thing(2).modified_on > 2012-09-08 09:22:28 > >>> db.thing(2).update_record(name='test4') > >>> print db.thing(2).modified_on > 2012-09-08 12:49:01 > > Massimo > > On Saturday, 8 September 2012 12:48:14 UTC-5, Massimo Di Pierro wrote: >> >> Supposed to work any update_record but let me give it a try. >> >> On Saturday, 8 September 2012 12:39:20 UTC-5, Joel Carrier wrote: >>> >>> At first I thought it was related to running on a windows machine using >>> the development server. >>> Then I deployed to a linux machine using the setup-web2py-ubuntu.sh >>> script >>> >>> Yes, the version is: Version 2.0.8 (2012-09-07 03:47:51) stable >>> >>> db.py: >>> >>> # -*- coding: utf-8 -*- >>> if 0: >>> from gluon.sql import * >>> from gluon.validators import * >>> from gluon import T >>> >>> >>> from gluon import current >>> >>> >>> db = SQLDB('mysql://'+settings.sql_user+':'+settings.sql_password+'@'+ >>> settings.db_host+'/'+settings.db_name,migrate=settings.migrate,pool_size >>> =10) >>> >>> >>> response.generic_patterns = ['*'] #if request.is_local else [] >>> >>> >>> current.db = db >>> current.T = T >>> >>> >>> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate >>> auth = Auth(db, hmac_key=settings.hmac_key, salt=True) >>> crud, service, plugins = Crud(db), Service(), PluginManager() >>> >>> >>> current.auth = auth >>> >>> >>> auth.settings.registration_requires_verification = True >>> auth.settings.registration_requires_approval = False >>> auth.settings.reset_password_requires_verification = True >>> >>> >>> db._common_fields.append(auth.signature) >>> >>> >>> db.define_table('auth_user', >>> Field('id','id'), >>> Field('first_name', type='string', >>> label=T('First Name')), >>> Field('last_name', type='string', >>> label=T('Last Name')), >>> Field('email', type='string', >>> label=T('Email')), >>> Field('password', type='password', >>> readable=False, >>> label=T('Password')), >>> Field('date_of_birth', type='date', >>> label=T('Date of Birth')), >>> Field('birth_country','integer'), >>> Field('birth_city'), >>> Field('registration_key',default='', >>> writable=False,readable=False), >>> Field('reset_password_key',default='', >>> writable=False,readable=False), >>> Field('registration_id',default='', >>> writable=False,readable=False), >>> format='[%(id)s] %(first_name)s %(last_name)s', >>> ) >>> >>> >>> db.auth_user.first_name.requires = IS_UPPER() >>> db.auth_user.last_name.requires = IS_UPPER() >>> db.auth_user.password.requires = CRYPT(key=auth.settings.hmac_key) >>> db.auth_user.registration_id.requires = IS_NOT_IN_DB(db, db.auth_user. >>> registration_id) >>> db.auth_user.email.requires = ( >>> IS_EMAIL(error_message=auth.messages.invalid_email), >>> IS_NOT_IN_DB(db, db.auth_user.email), >>> IS_UPPER() >>> ) >>> >>> >>> and in models directory i also have a z.py >>> >>> auth.enable_record_versioning(db) >>> >>> Do I have to update my entities using SQLForms only? Or is it suppose >>> to work with any .update_record()? >>> >>> Thanks for your help! >>> >>> >>> On Saturday, September 8, 2012 10:23:05 AM UTC-4, Massimo Di Pierro >>> wrote: >>>> >>>> I am trying to reproduce the problem but I cannot. Are you running >>>> 2.0.8? >>>> >>>> On Saturday, 8 September 2012 07:34:19 UTC-5, Joel Carrier wrote: >>>>> >>>>> I want to maintain an audit history of all my objects. >>>>> >>>>> So near the beginning of my model definition I have >>>>> >>>>> db._common_fields.append(auth.signature) >>>>> >>>>> and at the very end I have >>>>> >>>>> auth.enable_record_versioning(db) >>>>> >>>>> The problem I am having is that when I pull up all the records >>>>> representing the history of an object, the modified_by and modified_on >>>>> fields do not reflect the time and user that performed the change. In >>>>> fact, they appear to be stuck on whoever was logged in when I last >>>>> restart >>>>> the web2py server and the time at which I restarted it. (Maybe it's the >>>>> first person to perform an edit and the time they do it at since last >>>>> restart.) >>>>> >>>>> Anyway, is there something obvious I am missing here? >>>>> >>>> --