On Fri, Jan 16, 2009 at 7:02 PM, Tim Cook <timothywayne.c...@gmail.com> wrote:
> Thanks for all the assistance.
> On Fri, 2009-01-16 at 18:05 +0100, Martijn Faassen wrote:
>> Yes, you do create new schema fields by subclassing from Field.
>> It's just that we saw you putting a field not in a schema but in what
>> looked like a concrete object.
> This has given me a BIG pause while I'm working on a simpler example.
> It may actually solve the problem.
> Are you saying that in order to create a Field that can be used as an
> attribute of another class; I should define it in an interface and ONLY
> in an interface?
You should define a field as a subclass of Field (or of some more
specific Field). When you want to actually use the field you created,
you can only do so in an interface:
a = MyField(...)
You cannot store fields on concrete objects. You must have an
attribute on the concrete object that implements IMySchema that is
named the same as the field and is of the format defined by the field
(thus, a unicode string for a schema.Text field, and a list for a
Zope3-users mailing list