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 sys
24 import logging
25 log = logging.getLogger("zen.Relations")
26
27 from Globals import DTMLFile
28 from Globals import InitializeClass
29 from AccessControl import ClassSecurityInfo
30 from Acquisition import aq_base
31
32 from Products.ZenRelations.Exceptions import *
33 from Products.ZenRelations.utils import importClass
34
35 from PrimaryPathObjectManager import PrimaryPathManager
36
38 """
39 Abstract base class for all relationship classes.
40 """
41
42 _operation = -1
43
47
48
51
52
56
57
58 - def _add(self, obj):
61
62
64 """
65 Remove object from local side of relationship.
66 If obj=None remove all object in the relationship
67 """
68 raise NotImplementedError
69
70
74
75
93
94
99
100
102 """Return the type of the remote end of our relationship."""
103 schema = self.__primary_parent__.lookupSchema(self.id)
104 return schema.remoteType
105
106
108 """Return the type of the remote end of our relationship."""
109 schema = self.__primary_parent__.lookupSchema(self.id)
110 return schema.remoteType.__name__
111
112
114 """Return the class at the remote end of our relationship."""
115 classdef = getattr(aq_base(self), "_v_remoteClass", None)
116 if not classdef:
117 schema = self.__primary_parent__.lookupSchema(self.id)
118 classdef = importClass(schema.remoteClass)
119 self._v_remoteClass = classdef
120 return classdef
121
122
124 """Return the name at the remote end of our relationship."""
125 schema = self.__primary_parent__.lookupSchema(self.id)
126 return schema.remoteName
127
128
130 """Return our parent object by our primary path"""
131 return self.__primary_parent__.primaryAq()
132
133
135 """
136 Return the local class of this relationship. For all relationshps
137 this is the class of our __primary_parent___.
138 """
139 return self.__primary_parent__.__class__
140
141
143 """Don't let relationships move off their managers"""
144 return 0
145
146
148 """Don't let relationships move off their managers"""
149 return 0
150
151
153 """Check to make sure that relationship bidirectionality is ok.
154 """
155 return
156
157
158 InitializeClass(RelationshipBase)
159