This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
collective.dms.thesaurus/src/collective/dms/thesaurus/browser/view.py

39 lines
1.1 KiB
Python

from zope.component import getUtility
from zope.app.intid.interfaces import IIntIds
from zc.relation.interfaces import ICatalog
from plone.dexterity.browser.view import DefaultView
#from plone.dexterity.interfaces import IDexterityFTI
#from plone.dexterity.utils import getAdditionalSchemata
class DmsKeywordView(DefaultView):
"""The default view for DMSKeyword.
"""
@property
def children(self):
intids = getUtility(IIntIds)
catalog = getUtility(ICatalog)
value = []
try:
doc_intid = intids.getId(self.context)
except KeyError:
pass
else:
for ref in catalog.findRelations(
{'to_id': doc_intid, 'from_attribute': 'broader'}):
tp = dict(
url=ref.from_path,
label=ref.from_object.Title(),
hn=ref.from_object.historical_note,
sn=ref.from_object.scope_note
)
if tp not in value:
value.append(tp)
return value