1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""Manufacturer
15
16 Manufacturer is a base class that represents a vendor of Products.
17
18 $Id: Manufacturer.py,v 1.11 2004/03/26 23:58:44 edahl Exp $"""
19
20 __version__ = "$Revision: 1.11 $"[11:-2]
21
22 import types
23
24 from Globals import DTMLFile, InitializeClass
25 from AccessControl import ClassSecurityInfo
26 from AccessControl import Permissions as permissions
27
28 from Products.ZenRelations.RelSchema import *
29
30 from ZenModelRM import ZenModelRM
31 from ZenPackable import ZenPackable
32
33
43
44 addManufacturer = DTMLFile('dtml/addManufacturer',globals())
45
47 """Manufacturer object"""
48 portal_type = meta_type = 'Manufacturer'
49
50 url = ''
51 supportNumber = ''
52 address1 = ''
53 address2 = ''
54 city = ''
55 state = ''
56 zip = ''
57
58 _properties = (
59 {'id':'url', 'type':'string', 'mode':'w'},
60 {'id':'supportNumber', 'type':'string', 'mode':'w'},
61 {'id':'address1', 'type':'string', 'mode':'w'},
62 {'id':'address2', 'type':'string', 'mode':'w'},
63 {'id':'city', 'type':'string', 'mode':'w'},
64 {'id':'state', 'type':'string', 'mode':'w'},
65 {'id':'zip', 'type':'string', 'mode':'w'},
66 )
67
68 _relations = ZenPackable._relations + (
69 ("products", ToManyCont(ToOne,"Products.ZenModel.ProductClass","manufacturer")),
70 )
71
72
73 factory_type_information = (
74 {
75 'id' : 'Manufacturer',
76 'meta_type' : 'Manufacturer',
77 'description' : """Arbitrary device grouping class""",
78 'icon' : 'Manufacturer_icon.gif',
79 'product' : 'ZenModel',
80 'factory' : 'manage_addManufacturer',
81 'immediate_view' : 'viewManufacturerOverview',
82 'actions' :
83 (
84 { 'id' : 'overview'
85 , 'name' : 'Overview'
86 , 'action' : 'viewManufacturerOverview'
87 , 'permissions' : (permissions.view, )
88 },
89 { 'id' : 'edit'
90 , 'name' : 'Edit'
91 , 'action' : 'editManufacturer'
92 , 'permissions' : ("Manage DMD", )
93 },
94 { 'id' : 'config'
95 , 'name' : 'zProperties'
96 , 'action' : 'zPropertyEdit'
97 , 'permissions' : ("Manage DMD",)
98 },
99 { 'id' : 'viewHistory'
100 , 'name' : 'Modifications'
101 , 'action' : 'viewHistory'
102 , 'permissions' : (permissions.view, )
103 },
104 )
105 },
106 )
107
108 security = ClassSecurityInfo()
109
110
112 """Return the number of products for this manufacturer.
113 """
114 return self.products.countObjects()
115
116
124
125
134
135
150
151
153 """Add a product to this manufacturer based on its factory type.
154 """
155 prod = self._getOb(prodName, None)
156 if not prod:
157 prod = factory(prodName)
158 self.products._setObject(prod.id, prod)
159 prod = self.products._getOb(prod.id)
160 return prod
161
162
169
170
178
179
180 security.declareProtected('Manage DMD', 'manage_editManufacturer')
181 - def manage_editManufacturer(self, id='',
182 url = '', supportNumber = '',
183 address1 = '', address2 = '',
184 city = '', state = '', zip = '', REQUEST=None):
200
201
202 InitializeClass(Manufacturer)
203