add definitions for relation and relation set schema fields

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3162 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2009-01-19 16:11:12 +00:00
parent c6245987a2
commit b28c81d9b4

View file

@ -1,5 +1,5 @@
# #
# Copyright (c) 2005 Helmut Merz helmutm@cy55.de # Copyright (c) 2009 Helmut Merz helmutm@cy55.de
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -17,16 +17,64 @@
# #
""" """
Specialized schema factories Specialized fields and schema factories
$Id$ $Id$
""" """
from zope.component import adapts from zope.component import adapts
from zope.interface import Attribute, implements
from zope.schema import Choice, List
from zope.schema.interfaces import IChoice, IList
from cybertools.composer.schema.factory import SchemaFactory from cybertools.composer.schema.factory import SchemaFactory
from loops.interfaces import IResourceAdapter, IFile, INote from loops.interfaces import IResourceAdapter, IFile, INote
# fields
class IRelation(IChoice):
""" An object addressed via a single relation.
"""
target_types = Attribute('A list of names that denote types of '
'loops objects (typically concept types) that may be used as '
'targets for the relation.')
class IRelationSet(IList):
""" A collection of objects addressed via a set of relations.
Despite its name, the collection may have a predefined order.
"""
target_types = Attribute('A list of names that denote types of '
'loops objects (typically concept types) that may be used as '
'targets for the relations.')
class Relation(Choice):
implements(IRelation)
__typeInfo = ('relation',)
def __init__(self, *args, **kw):
self.target_types = kw.pop('target_types')
super(Relation, self).__init__(*args, **kw)
class RelationSet(List):
implements(IRelationSet)
__typeInfo = ('relationset',)
def __init__(self, *args, **kw):
self.target_types = kw.pop('target_types')
super(RelationSet, self).__init__(*args, **kw)
# schema factories
class ResourceSchemaFactory(SchemaFactory): class ResourceSchemaFactory(SchemaFactory):