[Zope3-Users] Re: zope.schema Question
Tim Cook
timothywayne.cook at gmail.com
Mon Jul 7 03:20:01 EDT 2008
On Mon, 2008-07-07 at 00:46 +0200, Philipp von Weitershausen wrote:
>
> description=Object(
> schema=IFoo,
> ...
> )
>
> So the zope.schema.Object field is really about specifying objects that
> provide a certain schema. It's not for *arbitrary* objects (use
> zope.schema.Field or zope.interface.Attribute here).
Thanks Philipp.
Field doesn't work because it expects a unicode type.
Attribute works but I would like to be able to flag it as 'required'
which is not part of the Attribute class.
Object would work if it would allow types that subclass from the schema
given.
A concrete example:
IItemStructure(Interface)
IItemTree(IItemStructure)
IItemTable(IItemStructure)
...
ItemTree(ItemStructure)
implements(IItemTree)
ItemTable(ItemStructure)
implements(IItemTable)
...
Now I want to allow description to be any descendant of ItemStructure.
So I had hoped that:
description=Object(
schema=IItemStructure,
title=_(u"Description"),
description=_(u"Description of the activity."),
required=True,
)
would provide that functionality. It still throws a WrongTypeError.
I feel like the answer lies somewhere in the zope.interface.implement*
functions but I lack the Zen to get the right combination.
Thanks,
Tim
--
Timothy Cook, MSc
Health Informatics Research & Development Services
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
Skype ID == timothy.cook
**************************************************************
*You may get my Public GPG key from popular keyservers or *
*from this link http://timothywayne.cook.googlepages.com/home*
**************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20080707/3072e7f7/attachment-0001.bin
More information about the Zope3-users
mailing list