This append in a Form definition, when a callable is passed to a
validator used
in the Form.validator
Here is a short test case.
from turbogears import validators, controllers, widgets
def downcase(v):
return v.lower()
class MySchema(validators.Schema):
foo = validators.Wrapper(to_python=downcase)
class MyForm(widgets.TableForm):
fields = [
widgets.TextField('bar', label="Bar" ,
validator=validators.String(not_empty=True))
]
validator = MySchema()
myform=MyForm()
The problem is TG merge schema defined by MyForm.fields and
MyForm.validator.
A deepcopy of the second one generate an Exception.
I found the problem trying to create my own FormValidator that wrap a
function.
Here is the Traceback
Traceback (most recent call last):
File "./bug_validator.py", line 19, in ?
myform=MyForm()
File "/usr/lib/python2.4/site-packages/TurboGears-1.0.1-py2.4.egg/
turbogears/widgets/meta.py", line 168, in widget_init
validator = generate_schema(self.validator, widgets)
File "/usr/lib/python2.4/site-packages/TurboGears-1.0.1-py2.4.egg/
turbogears/widgets/meta.py", line 265, in generate_schema
schema = copy_schema(schema)
File "/usr/lib/python2.4/site-packages/TurboGears-1.0.1-py2.4.egg/
turbogears/widgets/meta.py", line 210, in copy_schema
return copy.deepcopy(schema)
File "/usr/lib/python2.4/copy.py", line 204, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.4/copy.py", line 351, in _reconstruct
state = deepcopy(state, memo)
File "/usr/lib/python2.4/copy.py", line 174, in deepcopy
y = copier(x, memo)
File "/usr/lib/python2.4/copy.py", line 268, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.4/copy.py", line 174, in deepcopy
y = copier(x, memo)
File "/usr/lib/python2.4/copy.py", line 268, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.4/copy.py", line 204, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.4/copy.py", line 351, in _reconstruct
state = deepcopy(state, memo)
File "/usr/lib/python2.4/copy.py", line 174, in deepcopy
y = copier(x, memo)
File "/usr/lib/python2.4/copy.py", line 268, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.4/copy.py", line 204, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.4/copy.py", line 336, in _reconstruct
y = callable(*args)
File "/usr/lib/python2.4/copy_reg.py", line 92, in __newobj__
return cls.__new__(cls, *args)
TypeError: function() takes at least 2 arguments (0 given)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---