Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Dev
Making PersistentList satisfy zope.schema.List
 

Index | Next | Previous | View Flat


paulcarduner at gmail

Jun 30, 2009, 12:17 PM


Views: 335
Permalink
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?

--
Paul Carduner
http://www.carduner.net
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]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 )

Subject User Time
Making PersistentList satisfy zope.schema.List paulcarduner at gmail Jun 30, 2009, 12:17 PM
    Re: Making PersistentList satisfy zope.schema.List dev at projekt01 Jun 30, 2009, 2:04 PM
        Re: Making PersistentList satisfy zope.schema.List agroszer at gmail Jul 1, 2009, 1:26 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.