2006/9/29, KLEIN Stéphane <[EMAIL PROTECTED]>:
2006/9/29, KLEIN Stéphane <[EMAIL PROTECTED]>:
> Hello,
>
> in one content component I've switch from IList to IDict schema and I
> note than IDict widget don't exist. It's normal ? if yes, why ?
I see that : http://mail.zope.org/pipermail/zope3-users/2006-June/003720.html
In mail http://mail.zope.org/pipermail/zope3-users/2006-June/003720.html
I don't know where put the last part :
from zope.schema.interfaces import WrongContainedType, ValidationError
from zope.schema import Dict
from zope.schema._field import AbstractCollection
def _validate_dict(value_type,key_type, value, errors=None):
if errors is None:
errors=[]
if value_type is None:
return errors
if key_type is None:
return errors
for (key,vl) in value.items():
try:
key_type.validate(key)
except ValidationError, error:
errors.append(error)
try:
value_type.validate(vl)
except ValidationError, error:
errors.append(error)
return errors
class FixedDict(Dict,AbstractCollection):
"""We have to fix the bind-method of Dict"""
def bind(self, object):
clone=AbstractCollection.bind(self,object)
if clone.key_type is not None:
clone.key_type = clone.key_type.bind(object)
return clone
def _validate(self,value):
errors=_validate_dict(self.value_type,self.key_type,value)
if len(errors) > 0:
raise WrongContainedType(errors)
First part is in browser/configure.zcml
Second part is in browser/widgets.py
But I don't know where put the last part.
Thanks four your help,
Stéphane
_______________________________________________
Zope3-users mailing list
[email protected]
http://mail.zope.org/mailman/listinfo/zope3-users