[Grok-dev] schema.List returns a list, but is it persistent?
Leonardo Rochael Almeida
leorochael at gmail.com
Wed Aug 26 11:25:26 EDT 2009
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.
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
More information about the Grok-dev