[Zope3-Users] How to extend File?

Stephan Richter srichter at cosmos.phy.tufts.edu
Mon Nov 22 08:10:04 EST 2004


On Thursday 18 November 2004 14:25, John Toews wrote:
> I'm trying to do something I thought would be very simple. I think I
> don't understand the Component Architecture well enough...
>
> I want to take the base File and simply add a property to it (a string
> representing a guid). That's all, everything else would remain the same.
> I've tried a couple different ways of doing:
>
> class IContentGuid(Interface):
>         guid = TextLine(title=_('guid desc'))
>
> class ContentBase(File):
>         zope.interface.implements(IContentGuid)
>
> And various configure.zcml setups. I can't really explain what's going
> wrong either. The best I've gotten is a link in the ZMI to ContentBase,
> which when clicked on will add an item, but after typing in a name and
> hitting Apply, a system error occurs. I think I'm just on the wrong
> track.
>
> Any ideas on what (all) I'm doing wrong?

I think Juergen gave you the full answer by now. Here are a couple 
philosophical comments:

1. The guid of an object should be provided by the UniqueId utility.

2. Even if you plan to add other fields, they are most likely meta-data and 
should be thus stored in annotations and accessed via an adapter. You do not 
want to create fat content objects. See the chapter on events (which should 
have really be called "Annotations and Events") to see how annotations can be 
setup.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-users mailing list