db.define_table('person',Field('name'),on_define=lambda table: [table.name.set_attributes(writable=False)]), thanks Jonathan
This commit is contained in:
@@ -1 +1 @@
|
||||
Version 2.00.0 (2012-08-23 09:00:53) dev
|
||||
Version 2.00.0 (2012-08-23 09:20:22) dev
|
||||
|
||||
+6
-1
@@ -174,7 +174,7 @@ import platform
|
||||
CALLABLETYPES = (types.LambdaType, types.FunctionType,
|
||||
types.BuiltinFunctionType,
|
||||
types.MethodType, types.BuiltinMethodType)
|
||||
TABLE_ARGS = ('migrate','primarykey','fake_migrate','format','singular','plural','trigger_name','sequence_name','common_filter','polymodel','table_class')
|
||||
TABLE_ARGS = ('migrate','primarykey','fake_migrate','format','singular','plural','trigger_name','sequence_name','common_filter','polymodel','table_class','on_define')
|
||||
|
||||
###################################################################################
|
||||
# following checks allow the use of dal without web2py, as a standalone module
|
||||
@@ -6977,6 +6977,8 @@ def index():
|
||||
sql_locker.release()
|
||||
else:
|
||||
table._dbt = None
|
||||
on_define = args.get('on_define',None)
|
||||
if on_define: on_define(table)
|
||||
return table
|
||||
|
||||
def __iter__(self):
|
||||
@@ -8149,6 +8151,9 @@ class Field(Expression):
|
||||
self.label = label if label!=None else fieldname.replace('_',' ').title()
|
||||
self.requires = requires if requires!=None else []
|
||||
|
||||
def set_attributes(self,*args,**attributes):
|
||||
self.__dict__.update(*args,**attributes)
|
||||
|
||||
def clone(self,point_self_references_to=False,**args):
|
||||
field = copy.copy(self)
|
||||
if point_self_references_to and \
|
||||
|
||||
Reference in New Issue
Block a user