From f165e4b1e8544d3fc0c91c14a374d78678492b8c Mon Sep 17 00:00:00 2001 From: helmutm Date: Thu, 31 Jul 2008 07:21:35 +0000 Subject: [PATCH] provide predicateInterface field for IPredicate; set up example 'IAllocated' git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2782 fd906abe-77d9-0310-91a1-e0d9ade77398 --- configure.zcml | 5 +++++ interfaces.py | 10 +++++----- organize/README.txt | 10 ++++++++++ organize/interfaces.py | 18 +++++++++++++++++- organize/party.py | 6 ++++-- organize/setup.py | 3 +++ predicate.py | 6 +++--- 7 files changed, 47 insertions(+), 11 deletions(-) diff --git a/configure.zcml b/configure.zcml index 017c533..bb85de0 100644 --- a/configure.zcml +++ b/configure.zcml @@ -406,6 +406,11 @@ component="loops.type.TypeInterfaceSourceList" name="loops.TypeInterfaceSource" /> + + diff --git a/interfaces.py b/interfaces.py index 330534f..8fdf8dd 100644 --- a/interfaces.py +++ b/interfaces.py @@ -620,7 +620,7 @@ class ITypeConcept(IConceptSchema): description=_(u'An interface that objects of this type can ' 'be adapted to'), default=None, - source="loops.TypeInterfaceSource", + source='loops.TypeInterfaceSource', required=False) viewName = schema.TextLine( @@ -645,13 +645,13 @@ class IPredicate(IConceptSchema): i.e. concepts of type 'predicate' should be adaptable to this interface. """ - typeInterface = schema.TextLine( #schema.Choice - title=_(u'Type Interface'), + predicateInterface = schema.Choice( + title=_(u'Predicate Interface'), description=_(u'Optional: allows specification of additional ' 'attributes of relations that are instances of this ' 'predicate.'), - default=u'', #None - #source="loops.TypeInterfaceSource", + default=None, + source='loops.PredicateInterfaceSource', required=False) diff --git a/organize/README.txt b/organize/README.txt index b6a789e..5bc74ff 100644 --- a/organize/README.txt +++ b/organize/README.txt @@ -355,6 +355,16 @@ Events listing >>> list(listing.events()) [] +Allocation of persons to tasks +------------------------------ + + >>> from loops.organize.interfaces import IAllocated + >>> predicate = concepts['predicate'] + >>> allocated = addAndConfigureObject(concepts, Concept, 'allocated', + ... title=u'allocated', + ... conceptType=predicate, predicateInterface=IAllocated) + + Fin de partie ============= diff --git a/organize/interfaces.py b/organize/interfaces.py index 04600c6..97fb115 100644 --- a/organize/interfaces.py +++ b/organize/interfaces.py @@ -34,6 +34,7 @@ from cybertools.organize.interfaces import IPerson as IBasePerson from cybertools.organize.interfaces import ITask from loops.interfaces import IConceptSchema from loops.organize.util import getPrincipalFolder +from loops import util from loops.util import _ ANNOTATION_KEY = 'loops.organize.person' @@ -141,7 +142,7 @@ class IMemberRegistrationManager(Interface): """ authPluginId = Attribute(u'The id of an authentication plugin to be ' - 'used for managing members of this loops site') + u'used for managing members of this loops site') def register(userId, password, lastName, firstName=u'', **kw): """ Register a new member for this loops site. @@ -161,3 +162,18 @@ class ITask(IConceptSchema, ITask): pass + +# 'allocated' predicate + +class IAllocated(Interface): + + allocType = schema.Choice( + title=_(u'Allocation Type'), + description=_(u'Specifies the kind of interaction a person or another ' + u'party has with the task or project it is allocated to.'), + source=util.KeywordVocabulary(( + ('standard', _(u'Standard')), + ('master', _(u'Master')), + )), + default='standard', + required=True) diff --git a/organize/party.py b/organize/party.py index 78cb2e1..022600a 100644 --- a/organize/party.py +++ b/organize/party.py @@ -40,16 +40,18 @@ from cybertools.typology.interfaces import IType from loops.common import AdapterBase from loops.concept import Concept from loops.interfaces import IConcept -from loops.organize.interfaces import IAddress -from loops.organize.interfaces import IPerson, ANNOTATION_KEY +from loops.organize.interfaces import IAddress, IPerson, IAllocated +from loops.organize.interfaces import ANNOTATION_KEY from loops.security.common import assignOwner, removeOwner, allowEditingForOwner from loops.type import TypeInterfaceSourceList +from loops.predicate import PredicateInterfaceSourceList from loops import util # register type interfaces - (TODO: use a function for this) TypeInterfaceSourceList.typeInterfaces += (IPerson, IAddress) +PredicateInterfaceSourceList.typeInterfaces += (IAllocated,) def getPersonForUser(context, request=None, principal=None): diff --git a/organize/setup.py b/organize/setup.py index 80d46a1..92abcff 100644 --- a/organize/setup.py +++ b/organize/setup.py @@ -46,6 +46,9 @@ class SetupManager(BaseSetupManager): owner = self.addObject(concepts, Concept, 'ownedby', title=u'owned by', conceptType=predicate) + #allocated = self.addAndConfigureObject(concepts, Concept, 'allocated', + # title=u'allocated', + # conceptType=predicate, predicateInterface=IAllocated) task = self.addAndConfigureObject(concepts, Concept, 'task', title=u'Task', conceptType=type, typeInterface=ITask) diff --git a/predicate.py b/predicate.py index a789d92..3bdb722 100644 --- a/predicate.py +++ b/predicate.py @@ -34,10 +34,10 @@ from loops.interfaces import ILoopsObject, IConcept, IResource from loops.interfaces import IPredicate from loops.concept import Concept from loops.common import AdapterBase -from loops.type import TypeInterfaceSourceList as BaseTypeInterfaceSourceList +from loops.type import TypeInterfaceSourceList -BaseTypeInterfaceSourceList.typeInterfaces += (IPredicate,) +TypeInterfaceSourceList.typeInterfaces += (IPredicate,) class Predicate(AdapterBase): @@ -49,7 +49,7 @@ class Predicate(AdapterBase): _contextAttributes = list(IPredicate) + list(IConcept) -class TypeInterfaceSourceList(BaseTypeInterfaceSourceList): +class PredicateInterfaceSourceList(TypeInterfaceSourceList): """ Collects type interfaces for predicates, i.e. interfaces that may be used for specifying additional attributes of relations. """