i found the root cause, it related with auth.signature
imho, the limitation for using before and after callback, it's not work 
when using auth.signature.
e.g. 1
in models/db.py
*not work*
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()

# append fields : auth.signature (root cause before and after callback not 
work)
*db._common_fields.append(auth.signature)*

# create table : store
db.define_table('store',
    Field('name', notnull=True),
    Field('website'),
    Field('image', 'upload', uploadfield = 'image_file'),
    Field('image_file', 'blob'), 
    format='%(name)s')

# create index : store
db.executesql('CREATE INDEX IF NOT EXISTS idx_store ON store (id, name);')

# enable_record_versioning : store
db.store._enable_record_versioning()

# create table : department
db.define_table('department',
    Field('department', notnull=True), 
    format='%(department)s')

# create index : department
db.executesql('CREATE INDEX IF NOT EXISTS idx_department ON department (id, 
department);')

# enable_record_versioning : department
db.department._enable_record_versioning()

# custom auth user table
auth.settings.extra_fields['auth_user']=[
    Field('gender', notnull=True),
    Field('address', 'text'),
    Field('zip_code'),
    Field('city'),
    Field('country'),
    Field('phone', 'list:string', notnull=True),
    Field('store', 'reference store', notnull=True),
    Field('department', 'reference department', notnull=True)]

## create all tables needed by auth if not custom tables
auth.define_tables(username=True, signature=True)

*work*
you must comment or delete it so that before and after callback can work.
#db._common_fields.append(auth.signature)

e.g. 2
the others thing i test is i define auth.signature for each table not using 
db._common_fields.append(auth.signature)
*not work*
db.define_table('department',
    Field('department', notnull=True), auth.signature, 
    format='%(department)s')

*work*
you must comment auth.signature, to make before and after callback work.
db.define_table('department',
    Field('department', notnull=True), *#auth.signature, *
    format='%(department)s')

please correct and forgive me if i'm wrong.
my question is :
how can i get the before and after callback work well with signature define 
on all of my tables?

thanks and best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.

Reply via email to