From 2e4f320fe7f091d925509ebbee84b36d620b9eaa Mon Sep 17 00:00:00 2001 From: helmutm Date: Thu, 1 Nov 2007 20:57:34 +0000 Subject: [PATCH] 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 --- relation/__init__.py | 9 ++++++--- relation/interfaces.py | 11 ++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/relation/__init__.py b/relation/__init__.py index 1860a7b..bef1d08 100644 --- a/relation/__init__.py +++ b/relation/__init__.py @@ -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): diff --git a/relation/interfaces.py b/relation/interfaces.py index f56e935..48c31b7 100644 --- a/relation/interfaces.py +++ b/relation/interfaces.py @@ -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. """