I have created two Dexterity types: lab_equipment.py, class_activity.py.
The class_activity type contains the following relation to the lab_activity type:
class_activity.py:
class IClassActivity(form.Schema, IImageScaleTraversable):
[...]
dexteritytextindexer.searchable('apparatus')
apparatus = RelationList(
title=_(u"Apparatus"),
description=_(u"Choose equipment used in this activity"),
value_type=RelationChoice(
source=ObjPathSourceBinder(
object_provides=ILabEquipment.__identifier__,
navigation_tree_query= {'path': {'query':'/Plone/ug-demos/equipment'}},
),
),
)
[...]
Now I need to list related members from the class_activity type in the lab_equipment page template.
Is there a way to reverse reference the RelationList from the class_activity type into the lab_activity type and then show this list into the page template?
To retrieve back-reference (all objects pointing to particular object using specified attribute) you can’t simply use from_object or from_path, because source object is stored in the relation without acquisition wrappers. You should use from_id and helper method, which search the object in the IntId catalog.
Please note, this method does not check effective and expiration date or content language.
In your case, you need to call this method from some method of lab equipment browser view and pass list of back referencing objects to your template. For example:
P.S. I copied the answer from my own Dexterity issue #234 I posted some time ago: http://code.google.com/p/dexterity/issues/detail?id=234&colspec=ID%20Type%20Status%20Priority%20Difficulty%20Milestone%20Owner%20Summary