1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""RelationshipBase
15
16 RelationshipBase is the base class for RelationshipManager
17 and ToManyRelationship.
18
19 $Id: RelationshipBase.py,v 1.26 2003/10/03 16:16:01 edahl Exp $"""
20
21 __version__ = "$Revision: 1.26 $"[11:-2]
22
23 import logging
24 log = logging.getLogger("zen.Relations")
25
26 from Globals import InitializeClass
27 from Acquisition import aq_base
28
29 from Products.ZenRelations.Exceptions import *
30 from Products.ZenRelations.utils import importClass
31
32 from PrimaryPathObjectManager import PrimaryPathManager
33
35 """
36 Abstract base class for all relationship classes.
37 """
38
39 _operation = -1
40
42 """Return the contents of this relation."""
43 raise NotImplementedError
44
45
48
49
51 """Does this relationship relate to obj."""
52 raise NotImplementedError
53
54
55 - def _add(self, obj):
56 """Add object to local side of relationship."""
57 raise NotImplementedError
58
59
61 """
62 Remove object from local side of relationship.
63 If obj=None remove all object in the relationship
64 """
65 raise NotImplementedError
66
67
69 """Remove obj form the remote side of this relationship."""
70 raise NotImplementedError
71
72
90
91
96
97
99 """Return the type of the remote end of our relationship."""
100 schema = self.__primary_parent__.lookupSchema(self.id)
101 return schema.remoteType
102
103
105 """Return the type of the remote end of our relationship."""
106 schema = self.__primary_parent__.lookupSchema(self.id)
107 return schema.remoteType.__name__
108
109
111 """Return the class at the remote end of our relationship."""
112 classdef = getattr(aq_base(self), "_v_remoteClass", None)
113 if not classdef:
114 schema = self.__primary_parent__.lookupSchema(self.id)
115 classdef = importClass(schema.remoteClass)
116 self._v_remoteClass = classdef
117 return classdef
118
119
121 """Return the name at the remote end of our relationship."""
122 schema = self.__primary_parent__.lookupSchema(self.id)
123 return schema.remoteName
124
125
127 """Return our parent object by our primary path"""
128 return self.__primary_parent__.primaryAq()
129
130
132 """
133 Return the local class of this relationship. For all relationshps
134 this is the class of our __primary_parent___.
135 """
136 return self.__primary_parent__.__class__
137
138
140 """Don't let relationships move off their managers"""
141 return 0
142
143
145 """Don't let relationships move off their managers"""
146 return 0
147
148
150 """Check to make sure that relationship bidirectionality is ok.
151 """
152 return
153
154
155 InitializeClass(RelationshipBase)
156