db.tablename.fieldname.readable = False # SAFE def test(): db.tablename.fieldname.readable = False # NOT SAFE
*models.py* def on_define_tablename(table): table.fieldname.readable = False # SAFE db.define_table('tablename', Field('fieldname'), on_define = on_define_tablename) BUT things like on_define = on_define_tablename are no longer necessary in web3py. Tables are defined when the files are imported not at every request (like in web2py) and therefore you do not need optimization tricks any more. On Friday, 14 June 2019 22:03:04 UTC-7, 黄祥 wrote: > > Be careful that you can no longer change attributes everywhere you like as >> in: >> >> db.tablename.fieldname.readable = False >> >> In web2py this is ok. In web3py this is not safe. Attributes must be >> global. The state of fixtures must not be modified inside actions. >> > > is it mean in controller not safe, but in on_define, safe or not ? > *e.g.* > *controller.py* > db.tablename.fieldname.readable = False # not safe in web3py > def test(): > db.tablename.fieldname.readable = False # not safe in web3py > > *models.py* > def on_define_tablename(table): > table.fieldname.readable = False # safe or not ? > db.define_table('tablename', > Field('fieldname'), > on_define = on_define_tablename) > > 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/82e955db-788c-4280-9504-0bbd242882eb%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.