add IMappingAttributeRelation and corresponding relation adapter for being able to use a set of child relations for representing a mapping attribute

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2809 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-08-13 17:39:10 +00:00
parent 3eafcd73d2
commit f2eb384dd8
4 changed files with 56 additions and 6 deletions

View file

@ -258,6 +258,14 @@
set_schema="loops.interfaces.IPredicate" />
</class>
<adapter factory="loops.predicate.MappingAttributeRelation" trusted="True" />
<class class="loops.predicate.MappingAttributeRelation">
<require permission="zope.View"
interface="loops.interfaces.IMappingAttributeRelation" />
<require permission="zope.ManageContent"
set_schema="loops.interfaces.IMappingAttributeRelation" />
</class>
<adapter factory="loops.query.QueryConcept" trusted="True" />
<class class="loops.query.QueryConcept">
<require permission="zope.View"

View file

@ -624,7 +624,7 @@ class ITypeConcept(IConceptSchema):
required=False)
viewName = schema.TextLine(
title=_(u'View name'),
title=_(u'View Name'),
description=_(u'Name of a special view be used for presenting '
'objects of this type.'),
default=u'',
@ -640,6 +640,8 @@ class ITypeConcept(IConceptSchema):
# storage = schema.Choice()
# predicates
class IPredicate(IConceptSchema):
""" Provided by predicates (predicate concepts that specify relation types),
i.e. concepts of type 'predicate' should be adaptable to this interface.
@ -655,6 +657,31 @@ class IPredicate(IConceptSchema):
required=False)
class IMappingAttributeRelation(IConceptSchema):
""" A relation based on a predicate ('mappingAttribute') that provides
values for an attribute name on a parent and a corresponding
identifiers on the the child objects that will be used as keys
on the parent's mapping attribute.
These values should be indexed by the relation registry to provide
direct access.
"""
attrName = schema.TextLine(
title=_(u'Attribute Name'),
description=_(u'Name of the mapping attribute this predicate '
'represents on the parent concept.'),
required=True)
attrIdentifier = schema.TextLine(
title=_(u'Child Identifier'),
description=_(u'Identifier of the child that may be used as a '
'key on the parent\'s mapping attribute.'),
required=True)
# resources
class IResourceAdapter(IBaseResourceSchema):
""" Base interface for adapters for resources. This is the base interface
of the interfaces to be used as typeInterface attribute on type concepts

View file

@ -17,7 +17,7 @@
#
"""
Predicate management.
Definition and management of special predicates and corresponding relations.
$Id$
"""
@ -31,7 +31,7 @@ from zope.security.proxy import removeSecurityProxy
from zope.traversing.api import getName
from loops.interfaces import ILoopsObject, IConcept, IResource
from loops.interfaces import IPredicate
from loops.interfaces import IPredicate, IMappingAttributeRelation
from loops.concept import Concept
from loops.common import AdapterBase
from loops.type import TypeInterfaceSourceList
@ -46,7 +46,7 @@ class Predicate(AdapterBase):
implements(IPredicate)
_contextAttributes = list(IPredicate) + list(IConcept)
_contextAttributes = list(IPredicate) # + list(IConcept)
class PredicateInterfaceSourceList(TypeInterfaceSourceList):
@ -56,3 +56,14 @@ class PredicateInterfaceSourceList(TypeInterfaceSourceList):
typeInterfaces = ()
# standard relation adapters
PredicateInterfaceSourceList.typeInterfaces += (IMappingAttributeRelation,)
class MappingAttributeRelation(AdapterBase):
implements(IMappingAttributeRelation)
_contextAttributes = list(IMappingAttributeRelation)

View file

@ -35,7 +35,7 @@ from cybertools.composer.schema.field import DateFieldInstance, BooleanFieldInst
from cybertools.composer.schema.field import EmailFieldInstance, ListFieldInstance
from cybertools.composer.schema.instance import Instance, Editor
from cybertools.relation.tests import IntIdsStub
from cybertools.relation.registry import RelationRegistry
from cybertools.relation.registry import RelationRegistry, IIndexableRelation
from cybertools.relation.interfaces import IRelation, IRelationRegistry
from cybertools.relation.interfaces import IRelationInvalidatedEvent
from cybertools.relation.registry import IndexableRelationAdapter
@ -54,7 +54,7 @@ from loops.interfaces import ILoopsObject, IIndexAttributes
from loops.interfaces import IDocument, IFile, ITextDocument
from loops.organize.memberinfo import MemberInfoProvider
from loops.organize.stateful.base import StatefulResourceIndexInfo, handleTransition
from loops.predicate import Predicate
from loops.predicate import Predicate, MappingAttributeRelation
from loops.query import QueryConcept
from loops.query import QueryConcept
from loops.resource import Resource, FileAdapter, TextDocumentAdapter
@ -95,6 +95,9 @@ class TestSite(object):
component.provideUtility(IntIdsStub())
relations = RelationRegistry()
relations.setupIndexes()
for idx in ('_attrName', '_attrIdentifier'):
if idx not in relations:
relations[idx] = FieldIndex(idx, IIndexableRelation)
component.provideUtility(relations, IRelationRegistry)
component.provideUtility(PrincipalAnnotationUtility(), IPrincipalAnnotationUtility)
@ -112,6 +115,7 @@ class TestSite(object):
component.provideAdapter(LoopsType)
component.provideAdapter(ConceptType)
component.provideAdapter(Predicate)
component.provideAdapter(MappingAttributeRelation)
component.provideAdapter(ResourceType, (IDocument,))
component.provideAdapter(TypeConcept)
component.provideAdapter(QueryConcept)