[Zope3-Users] How to resolve bi-directionally navigable association?

Adam Groszer adamg at fw.hu
Mon Aug 8 05:45:56 EDT 2005


As the subject sais, how can I resolve bi-directionally navigable
association in Z3?
Both objects have to have references of each other, that means that
also the schemas have to have references.

class IItem(interface):
    unit = Object(
        title=u"Unit",
        description=u"Unit",
        required = False,
        schema=IUnit)

class IUnit(interface):
    item = Object(
        title=u"Item",
        description=u"Item",
        required = False,
        schema=IItem)

but obviously that does not work, I cannot define one before the
other.

The only way I found is defining a dummy interface before the other:
class IUnit(interface):
      pass

class IItem(interface):
    unit = Object(
        title=u"Unit",
        description=u"Unit",
        required = False,
        schema=IUnit)

class IUnit(interface):
    item = Object(
        title=u"Item",
        description=u"Item",
        required = False,
        schema=IItem)

Is there any better solution?
-- 
Best regards,
 Adam                          mailto:adamg at fw.hu




More information about the Zope3-users mailing list