Hi Paul
-Ursprüngliche Nachricht-
Von: zope-dev-boun...@zope.org
[mailto:zope-dev-boun...@zope.org] Im Auftrag von Paul Carduner
Gesendet: Dienstag, 30. Juni 2009 21:18
An: zope-dev
Betreff: [Zope-dev] Making PersistentList satisfy zope.schema.List
I noticed that PersistentList and PersistentDict do not
satisfy zope.schema.List or zope.schema.Dict, which is rather
annoying. For
example:
class IBlogPost(Interface):
tags = zope.schema.List(title=u'Tags',
value_type=zope.schema.TextLine)
class BlogPost(Persistent):
implements(IBlogPost)
tags = FieldProperty(IBlogPost['tags'])
def __init__(self):
super(BlogPost, self).__init__()
self.tags = persistent.list.PersistentList() #aaah,
WrongType error...
will throw a WrongType: ([], type 'list') error, which is
especially confusing because the repr for PersistentList
makes it look an awful lot like a regular list.
same thing happens with PersistentDict.
I would like to modify zope.schema._bootstrapfields by
changing the _type attribute of the List class to (list,
UserList), and do the same for Dict with (dict, UserDict).
Then anything inheriting from UserList (including
PersistentList) will satisfy the schema.
Can anyone think of a reason why this would be bad?
I think it's different. If you use a zope.schem.List field
the widgets will store the list at once. This whould replace
the initial created PeristentList. (or not?)
In general if you store a simple list as attribute on a
persistent class it's fine, everything is stored.
If you like to append or pop from this list, then yes, you
will need a PersistentList otherwise the changes in the
list are not stored back to the DB. (right?)
Fazit,
the zope.schema.List field and the Sequence widget
is not compatible with initial PersitentList beause
the widget will probably replace the list with a
simple list.
Note, I'm not 100% sure if I'm correct. But it is at
least something which we have to make sure that this
is working.
Regards
Roger Ineichen
--
Paul Carduner
http://www.carduner.net
___
Zope-Dev maillist - Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! ** (Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )
___
Zope-Dev maillist - Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )