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/dmskeyword.py

83 lines
1.9 KiB
Python
Raw Normal View History

#import datetime
from Acquisition import aq_parent
from zope.interface import implements
2013-01-22 13:14:22 +01:00
2013-01-24 10:21:09 +01:00
from zope import schema
2013-01-22 13:14:22 +01:00
from plone.dexterity.schema import DexteritySchemaPolicy
from plone.dexterity.content import Item
2013-01-22 13:14:22 +01:00
from plone.supermodel import model
2013-01-22 13:14:22 +01:00
from . import _
from .keywordsfield import ThesaurusKeywords
from .equivalencesfield import ThesaurusKeywordEquivalences
from .dmsthesaurus import NoThesaurusFound
2013-01-22 13:14:22 +01:00
class IDmsKeyword(model.Schema):
""" """
# EQ: equivalences
2013-01-24 15:41:32 +01:00
equivs = ThesaurusKeywordEquivalences(
title=_(u'EQ (Equivalences)'),
2013-01-24 10:21:09 +01:00
required=False,
)
# BT: broader term
broader = ThesaurusKeywords(
2013-01-24 10:21:09 +01:00
title=_(u"BT (Broader Terms)"),
required=False,
vocabulary=u'dms.thesaurus.internalrefs'
2013-01-24 10:21:09 +01:00
)
# RT: related term
related = ThesaurusKeywords(
2013-01-24 10:21:09 +01:00
title=_(u"RT (Related Terms)"),
required=False,
display_backrefs=True,
vocabulary=u'dms.thesaurus.internalrefs'
)
# HN: historical note
historical_note = schema.Text(
2013-04-11 12:11:23 +02:00
title=_(u"HN (Historical Note)"),
required=False,
)
# SN: scope note
scope_note = schema.Text(
2013-04-11 12:11:23 +02:00
title=_(u"SN (Scope Note)"),
required=False,
2013-01-24 10:21:09 +01:00
)
def thesaurus():
"""get parent thesaurus"""
def thesaurusPath():
"""get parent thesaurus physical path"""
2013-01-24 10:21:09 +01:00
class DmsKeyword(Item):
2013-01-22 13:14:22 +01:00
""" """
implements(IDmsKeyword)
def thesaurus(self):
thesaurus = self
while thesaurus.portal_type != "dmsthesaurus":
thesaurus = aq_parent(thesaurus)
if not hasattr(thesaurus, 'portal_type') or getattr(thesaurus, 'portal_type', None) is None:
raise NoThesaurusFound
return thesaurus
def thesaurusPath(self):
return self.thesaurus().getPhysicalPath()
2013-01-22 13:14:22 +01:00
class DmsKeywordSchemaPolicy(DexteritySchemaPolicy):
""" """
def bases(self, schemaName, tree):
return (IDmsKeyword, )