Trees | Indices | Help |
|
---|
|
1 ############################################################################## 2 # 3 # Copyright (C) Zenoss, Inc. 2007, all rights reserved. 4 # 5 # This content is made available according to terms specified in 6 # License.zenoss under the directory where your Zenoss product is installed. 7 # 8 ############################################################################## 9 10 11 import Globals 12 from AccessControl import ClassSecurityInfo 13 from Products.ZenWidgets import messaging 1416 security = ClassSecurityInfo() 17 18 security.declareProtected('Manage DMD', 'addToZenPack')7920 "Add elements from a displayed list of objects to a ZenPack" 21 from Products.ZenModel.ZenPackable import ZenPackable 22 from Products.ZenModel.ZenPack import ZenPack 23 ids = list(ids) + list(organizerPaths) 24 message = "You must provide a valid ZenPack" 25 if pack: 26 pack = self.dmd.ZenPackManager.packs._getOb(pack) 27 message = 'Saved to %s' % pack.id 28 if ids: 29 for id in ids: 30 try: 31 obj = self.findObject(id) 32 except AttributeError, ex: 33 message = str(ex) 34 break 35 obj.buildRelations() 36 pack.packables.addRelation(obj) 37 else: 38 if isinstance(self, ZenPackable): 39 self.buildRelations() 40 pack.packables.addRelation(self) 41 else: 42 message = 'Nothing to save' 43 if REQUEST: 44 if isinstance(pack, ZenPack): 45 messaging.IMessageSender(self).sendToBrowser( 46 'Add To ZenPack', message) 47 return REQUEST['RESPONSE'].redirect('/zport/dmd/ZenPackManager' + 48 '/packs/%s' % pack.id if pack else '')4951 "Ugly hack for inconsistent object structure accross Organizers" 52 result = [] 53 try: 54 result.append(self._getOb(id)) 55 except AttributeError: 56 pass 57 for name, relationship in self._relations: 58 try: 59 result.append(getattr(self, name)._getOb(id)) 60 except AttributeError: 61 pass 62 if len(result) == 0: 63 try: 64 result.append(self.dmd.unrestrictedTraverse(id)) 65 except KeyError: 66 pass 67 if len(result) == 1: 68 return result[0] 69 raise AttributeError('Cannot find a unique %s on %s' % (id, self.id))70 7173 """ 74 Return a list of zenpacks that objects can be added to. (The 75 development mode zenpacks.) 76 """ 77 return [zp for zp in self.dmd.ZenPackManager.packs() 78 if zp.isDevelopment()]
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1.1812 on Mon Jul 30 17:11:21 2012 | http://epydoc.sourceforge.net |