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