[Zope3-dev] Re: ReferenceField equivalent

Philipp von Weitershausen philipp at weitershausen.de
Sun Jun 13 07:05:56 EDT 2004


Michal Wegrzynek wrote:
> I'm trying to connect the Album and Track objects with Artist performing
> them. In Plone I used the ReferenceField, which enables one Archetype
> object to link to others. What is the closest match for it in z3?

As Stephan said, we do not have to rely on references using unique ids
anymore. You directly store the object as an attribute:

>>> alan_parsons = Artist()
>>> i_robot = Album()
>>> i_robot.artist = alan_parsons

The schema field that describes such a relation ship is the
zope.schema.Object field:

class IArtist(Interface):
   pass

class IAlbum(Interface):
   ...

   # artist must be an object providing IArtist
   artist = Object(IArtist)

However, you then loose the ability to edit album objects through-the-web.

> I was thinking about using VocabularyField with some vocabulary class
> using ArtistContainer with fixed name as the source of information. 
> Is this the right approach or is there a better way?

If you want it to be editable through-the-web, that would be the way to go.

Edoardo ''Dado'' Marcora wrote:
> thanx for your reply to Micha's post. Do you have an example of code on how
> to store a reference to another object directly? Would it be just a simple
> assignment? Would it be possible to back-track these references?
> 
> Is that why the HubId service is not included in ZX3? And what is the
> equivalent of the Catalog in ZX3?

The HubId service has been ripped out. Its functionality is currently
being reimplemented as a utility that provides unique ids for objects.
The Zope3 catalog will use this utility, among others.

Philipp




More information about the Zope3-dev mailing list