[Grok-dev] schema.List returns a list, but is it persistent?

Sebastian Ware sebastian at urbantalk.se
Wed Aug 26 11:50:51 EDT 2009

A bug in applyData when I come to think about it... so I filed it :)

Mvh Sebastian

On 26 aug 2009, at 17.36, Sebastian Ware wrote:

> That is true, however I would definitely call that behaviour a bug in
> schema.List. The assumption that only data manipulation is done with
> applyData sounds risky. You could get some pretty creepy bugs...
> Anyway, I'll look into your suggestion.
> A suggestion is to change the behaviour of applyData so that it
> returns PersistentList.
> Mvh Sebastian
> On 26 aug 2009, at 17.25, Leonardo Rochael Almeida wrote:
>> IIRC, It is only a problem if you try to modify the list itself
>> directly (like appending to, or extending the list,  or removing or
>> replacing items or slices in the list). schema.List returns a new  
>> list
>> for every form submission, instead of trying to alter the old list to
>> include the new items. This new list is assigned to the object during
>> applyData, so it will be persisted correctly.
>> On the other hand, it's very easy to create your own class that
>> extends from schema.List to return your own datatype. IIRC you only
>> have to override one attribute in the subclass, and it will receive
>> the same widgets as the superclass unless you register differently or
>> alter the implemented interfaces.
>> Cheers, Leo
>> On Wed, Aug 26, 2009 at 11:56, Sebastian
>> Ware<sebastian at urbantalk.se> wrote:
>>> Lists need to be implemented as PersistentList in order to be
>>> automatically persisted to ZODB, however schema.List returns an
>>> ordinary list and applyData seemingly stores this list as is. Isn't
>>> this a big problem?
>>>    tags = schema.List(title=u"Content Tags",
>>> value_type=schema.Choice(title=u"Content Tag",
>>>           vocabulary='Content Tags'), default = [])
>>> Mvh Sebastian
>>> _______________________________________________
>>> Grok-dev mailing list
>>> Grok-dev at zope.org
>>> http://mail.zope.org/mailman/listinfo/grok-dev
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev

More information about the Grok-dev mailing list