Re: [Zope3-Users] Re: schema.List validation does not accept PersistentList

2007-07-19 Thread Fred Drake

On 7/19/07, Alek Kowalczyk [EMAIL PROTECTED] wrote:

Thanks! List should be list, whether it is persistent or not, but it's the
simplest solution...


You probably want to check the results of the edit widgets; they might
produce list values instead of PersistentList values.  Widgets are not
expected to edit the value in place, but to produce a new value.


 -Fred

--
Fred L. Drake, Jr.fdrake at gmail.com
Chaos is the score upon which reality is written. --Henry Miller
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: schema.List validation does not accept PersistentList

2007-07-19 Thread Fred Drake

On 7/19/07, Leonardo Rochael [EMAIL PROTECTED] wrote:

They seem to do the right thing (I fixed one of the cases when it didn't).
Check zope/app/form/browser/itemswidgets.py:MultiDataHelper._toFieldValue()

...

if hasattr(self.context, '_type'):
_type = self.context._type
if isinstance(_type, tuple):
_type = _type[0]
return _type(values)


Ah, so they have to violate encapsulation to do it.  I'd suggest this
is a hack, as it

- references a protected member of the context

- makes assumptions about how instances of the type are constructed

These are moderately safe assumptions in practice, but they're exactly that.


 -Fred

--
Fred L. Drake, Jr.fdrake at gmail.com
Chaos is the score upon which reality is written. --Henry Miller
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users