1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 __doc__="""$Id: ToManyRelationship.py,v 1.48 2003/11/12 22:05:48 edahl Exp $"""
16
17 __version__ = "$Revision: 1.48 $"[11:-2]
18
19
20
21 from RelationshipBase import RelationshipBase
22 from RelCopySupport import RelCopyContainer
23 from OFS.Traversable import Traversable
24 from Acquisition import Implicit
25
26 from Globals import DTMLFile
27 from Acquisition import aq_base, aq_parent
28 from AccessControl import ClassSecurityInfo
29 from Globals import InitializeClass
30 from App.Management import Tabs
31
32 from Products.ZenRelations.Exceptions import zenmarker
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
75
76
78 """don't use attributes in relations"""
79 raise NotImplementedError
80
81
85
86
88 """
89 Return object by id if it exists on this relationship.
90 If it doesn't exist return default or if default is not set
91 raise AttributeError
92 """
93 raise NotImplementedError
94
95
97 """if this has been called on us return our workspace
98 if not redirect to the workspace of a related object"""
99 id = REQUEST['URL'].split('/')[-2]
100 if id == self.id:
101 Tabs.manage_workspace(self, REQUEST)
102 else:
103 obj = self._getOb(self, id)
104 raise "Redirect", (obj.getPrimaryUrlPath()+'/manage_workspace')
105
106
107 InitializeClass(ToManyRelationshipBase)
108