Agility Type RelationList Countdown

I created two types of Dexterity: 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 the related members from the class_activity class in the lab_equipment page template.

Is there a way to unlink the RelationList from class_activity to lab_activity and then display this list in the page template?

+3
source share
1 answer

( , , ), from_object from_path, . from_id helper, IntId.

from Acquisition import aq_inner
from zope.component import getUtility
from zope.intid.interfaces import IIntIds
from zope.security import checkPermission
from zc.relation.interfaces import ICatalog


def back_references(source_object, attribute_name):
    """ Return back references from source object on specified attribute_name """
    catalog = getUtility(ICatalog)
    intids = getUtility(IIntIds)
    result = []
    for rel in catalog.findRelations(
                            dict(to_id=intids.getId(aq_inner(source_object)),
                                 from_attribute=attribute_name)
                            ):
        obj = intids.queryObject(rel.from_id)
        if obj is not None and checkPermission('zope2.View', obj):
            result.append(obj)
    return result

, , .

. :

class LabEquipmentView(BrowserView):

    def aparatus_backrefs(self):
        return back_references(self.context, 'apparatus')

P.S. # 234, : http://code.google.com/p/dexterity/issues/detail?id=234&colspec=ID%20Type%20Status%20Priority%20Difficulty%20Milestone%20Owner%20Summary

+3

All Articles