I disagree<br>This is not a flaw in schema.List<br>your usecase is to make it persist. But, it's the unique usecase of a form.<br>However, a simple list is persistent, just doesn't trigger an update warning for the ZODB if modified.<br>
<br><div class="gmail_quote">2009/8/26 Sebastian Ware <span dir="ltr"><<a href="mailto:sebastian@urbantalk.se">sebastian@urbantalk.se</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
A bug in applyData when I come to think about it... so I filed it :)<br>
<br>
Mvh Sebastian<br>
<div><div></div><div class="h5"><br>
On 26 aug 2009, at 17.36, Sebastian Ware wrote:<br>
<br>
> That is true, however I would definitely call that behaviour a bug in<br>
> schema.List. The assumption that only data manipulation is done with<br>
> applyData sounds risky. You could get some pretty creepy bugs...<br>
><br>
> Anyway, I'll look into your suggestion.<br>
><br>
> A suggestion is to change the behaviour of applyData so that it<br>
> returns PersistentList.<br>
><br>
> Mvh Sebastian<br>
><br>
> On 26 aug 2009, at 17.25, Leonardo Rochael Almeida wrote:<br>
><br>
>> IIRC, It is only a problem if you try to modify the list itself<br>
>> directly (like appending to, or extending the list, or removing or<br>
>> replacing items or slices in the list). schema.List returns a new<br>
>> list<br>
>> for every form submission, instead of trying to alter the old list to<br>
>> include the new items. This new list is assigned to the object during<br>
>> applyData, so it will be persisted correctly.<br>
>><br>
>> On the other hand, it's very easy to create your own class that<br>
>> extends from schema.List to return your own datatype. IIRC you only<br>
>> have to override one attribute in the subclass, and it will receive<br>
>> the same widgets as the superclass unless you register differently or<br>
>> alter the implemented interfaces.<br>
>><br>
>> Cheers, Leo<br>
>><br>
>> On Wed, Aug 26, 2009 at 11:56, Sebastian<br>
>> Ware<<a href="mailto:sebastian@urbantalk.se">sebastian@urbantalk.se</a>> wrote:<br>
>>> Lists need to be implemented as PersistentList in order to be<br>
>>> automatically persisted to ZODB, however schema.List returns an<br>
>>> ordinary list and applyData seemingly stores this list as is. Isn't<br>
>>> this a big problem?<br>
>>><br>
>>> tags = schema.List(title=u"Content Tags",<br>
>>> value_type=schema.Choice(title=u"Content Tag",<br>
>>> vocabulary='Content Tags'), default = [])<br>
>>><br>
>>> Mvh Sebastian<br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> Grok-dev mailing list<br>
>>> <a href="mailto:Grok-dev@zope.org">Grok-dev@zope.org</a><br>
>>> <a href="http://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">http://mail.zope.org/mailman/listinfo/grok-dev</a><br>
>>><br>
><br>
> _______________________________________________<br>
> Grok-dev mailing list<br>
> <a href="mailto:Grok-dev@zope.org">Grok-dev@zope.org</a><br>
> <a href="http://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">http://mail.zope.org/mailman/listinfo/grok-dev</a><br>
<br>
_______________________________________________<br>
Grok-dev mailing list<br>
<a href="mailto:Grok-dev@zope.org">Grok-dev@zope.org</a><br>
<a href="http://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">http://mail.zope.org/mailman/listinfo/grok-dev</a><br>
</div></div></blockquote></div><br>