It is 

auth.enable_record_versioning(db)

not 

auth.enable_record_versioning=True # Doh!

On Monday, 8 October 2012 15:21:48 UTC-5, Massimo Di Pierro wrote:
>
> There are two ways to do record versioning in web2py:
>
> - the old way using auth.archive (the one you are using). When a record is 
> modified the old record is copied into the archive table. When a record is 
> deleted, it is actually deleted and a copy of the old one is saved.
>
> - the new way auth.enable_record_versioning(db) or 
> db.table._enable_record_versioning(). This uses the before_* and after_* 
> callbacks. When the record is modified it acts as in the case above. When 
> the record is deleted it is not actually deleted but is_active is set to 
> false and all queries are filtered by is_active = True.
>
>
> On Monday, 8 October 2012 14:04:09 UTC-5, Cliff Kachinske wrote:
>>
>> I have the following, but checking the delete box actually deletes the 
>> record rather than setting is_active to False.
>>
>> It creates records in the archive table, but I also want them to stay in 
>> the main table with is_active set to False.
>>
>> What am I doing wrong?
>>
>> Thank you,
>> Cliff Kachinske
>>
>> Model
>> db.define_table('documentation',
>>     Field('name', length=36, label='Name'),
>>     # I put this in just before Massimo announced request_tenant
>>     # Timing is everything!
>>     Field('tenant_link', db.tenants, 
>>          default=session.auth.user.tenant_link),
>>     auth.signature,
>>     format='%(name)s')
>> db.documentation.tenant_link.requires = IS_IN_DB(
>>     db, db.tenants.id, '%(name)s', zero='Choose')
>> db.documentation.tenant_link.readable = False
>> db.documentation.tenant_link.writable = False
>>
>> #More tables ...
>>
>> auth.enable_record_versioning(db)
>> db.auth_permission.table_name.requires = IS_IN_SET(db.tables)
>>
>> Controller:
>> def edit():
>>     form = crud.update(
>>            db.documentation, request.args(0), next=next,
>>            # Commented out to avoid multiple records in the archive table 
>> while testing
>>            # Does not affect the problem either way
>>            # onaccept=auth.archive,
>>            )
>>     return dict(form=form, h2='Edit')
>>
>>
>>

-- 



Reply via email to