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

Sebastian Ware sebastian at urbantalk.se
Wed Aug 26 12:26:38 EDT 2009


I eventually realised that :) but I do think it is a bug in applyData,  
since you would really expect applyData to return automatically  
persistent data types (at least as default). Right now it is kind of  
"it just works... most of the time...".

Mvh Sebastian

On 26 aug 2009, at 18.13, Leonardo Rochael Almeida wrote:

> On Wed, Aug 26, 2009 at 12:25, Leonardo Rochael
> Almeida<leorochael at gmail.com> wrote:
>>
>> [...]
>>
>> 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.
>
> The attribute is _type, btw. The reason PersistentList is not the
> default is because zope.schema doesn't assume you're going to use it
> with zodb.
>
> Cheers, Leo
>
>>
>> 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
>>>
>>



More information about the Grok-dev mailing list