added order and relevance attributes to Relation class

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2138 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2007-11-01 20:57:34 +00:00
parent 24206693f9
commit 2e4f320fe7
2 changed files with 16 additions and 4 deletions

View file

@ -35,6 +35,9 @@ class Relation(Persistent):
implements(IPredicate, IRelation)
order = 0
relevance = 1.0
@classmethod
def getPredicateName(cls):
return '%s.%s' % (cls.__module__, cls.__name__)
@ -47,10 +50,10 @@ class Relation(Persistent):
if obj is not None and not IRelatable.providedBy(obj):
raise(ValueError, 'Objects to be used in relations '
'must provide the IRelatable interface.')
class DyadicRelation(Relation):
implements(IDyadicRelation)
def __init__(self, first, second):
@ -60,7 +63,7 @@ class DyadicRelation(Relation):
class TriadicRelation(Relation):
implements(ITriadicRelation)
def __init__(self, first, second, third):

View file

@ -32,6 +32,13 @@ class IRelation(Interface):
""" Base interface for relations.
"""
order = Attribute('An integer that may be used for ordering relations. '
'The default should be 0, and there may be negative and '
'positive values.')
relevance = Attribute('A float greater than 0.0 and less or equal to '
'1.0 denoting the importance, relevance, or weight of a '
'relation. The default and standard value should be 1.0.')
def getPredicateName():
""" Return the predicate of this relation as a string that may be
used for indexing.
@ -41,7 +48,9 @@ class IRelation(Interface):
""" Return True if this relation is valid.
If the registry argument is provided the check should be done
with respect to this relation registry, e.g. to
with respect to this relation registry. The validate() method
may be used for implementing checks against ontologies or other
kinds of restrictions.
"""