1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 __doc__ = """ToManyRelationshipBase
16 Base class for 1:n relations
17 """
18 import logging
19 log = logging.getLogger('zen.ToManyRelationshipBase')
20
21
22
23 from RelationshipBase import RelationshipBase
24 from RelCopySupport import RelCopyContainer
25
26 from Globals import DTMLFile
27 from AccessControl import ClassSecurityInfo
28 from Globals import InitializeClass
29 from App.Management import Tabs
30
31 from Products.ZenRelations.Exceptions import zenmarker
32 from Products.ZenUtils.Utils import unused
33
38 """
39 Abstract base class for all ToMany relationships.
40 """
41
42 manage_options = (
43 {
44 'action': 'manage_main',
45 'help': ('OFSP', 'ObjectManager_Contents.stx'),
46 'label': 'Contents'},
47 )
48
49 security = ClassSecurityInfo()
50
51 manage_main = DTMLFile('dtml/ToManyRelationshipMain',globals())
52
53 _operation = -1
54
55
57 """Return the number of objects in this relationship"""
58 return len(self._objects)
59
60
68
69
71 """Emulate ObjectManager deletetion."""
72 unused(dp)
73 obj = self._getOb(id, False)
74 if not obj:
75 log.warning(
76 "Tried to delete object id '%s' but didn't find it on %s",
77 id, self.getPrimaryId())
78 return
79 self.removeRelation(obj)
80 obj.__primary_parent__ = None
81
82
84 """don't use attributes in relations"""
85 unused(id)
86 unused(obj)
87 if True:
88 raise NotImplementedError
89
90
92 """don't use attributes in relations"""
93 if True:
94 raise NotImplementedError
95
96
98 """
99 Return object by id if it exists on this relationship.
100 If it doesn't exist return default or if default is not set
101 raise AttributeError
102 """
103 unused(default)
104 if True:
105 raise NotImplementedError
106
107
109 """if this has been called on us return our workspace
110 if not redirect to the workspace of a related object"""
111 id = REQUEST['URL'].split('/')[-2]
112 if id == self.id:
113 Tabs.manage_workspace(self, REQUEST)
114 else:
115 obj = self._getOb(self, id)
116 from zExceptions import Redirect
117 raise Redirect( (obj.getPrimaryUrlPath()+'/manage_workspace') )
118
119
120 InitializeClass(ToManyRelationshipBase)
121