Package Products :: Package Zuul :: Package routers :: Module settings
[hide private]
[frames] | no frames]

Source Code for Module Products.Zuul.routers.settings

 1  ############################################################################## 
 2  #  
 3  # Copyright (C) Zenoss, Inc. 2010, 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  """ 
12  Operations for Settings. 
13   
14  Available at:  /zport/dmd/settings_router 
15  """ 
16  from Products.ZenUtils.Ext import DirectRouter 
17  from Products.ZenUtils.extdirect.router import DirectResponse 
18  from Products.Zuul.decorators import require 
19  from Products import Zuul 
20  from Products.ZenMessaging.audit import audit 
21 22 23 -class SettingsRouter(DirectRouter):
24 """ 25 A JSON/ExtDirect interface to operations on settings 26 """ 27
28 - def _getUISettings(self):
29 return self.context.zport.dmd.UserInterfaceSettings
30
32 """ 33 Retrieves the collection of User interface settings 34 """ 35 settings = self._getUISettings() 36 return DirectResponse.succeed(data=Zuul.marshal(settings.getSettingsData()))
37 38 @require('Manage DMD')
39 - def setUserInterfaceSettings(self, **kwargs):
40 """ 41 Accepts key value pair of user interface settings. 42 """ 43 settings = self._getUISettings() 44 oldValues = {} 45 newValues = {} 46 for key, value in kwargs.iteritems(): 47 oldValues[key] = str(getattr(settings, key, None)) 48 newValues[key] = str(value) 49 setattr(settings, key, value) 50 audit('UI.InterfaceSettings.Edit', data_=newValues, oldData_=oldValues) 51 return DirectResponse.succeed()
52 53 @require('Manage DMD')
54 - def setDmdSettings(self, **kwargs):
55 """ 56 Accepts key value pair of dmd settings 57 """ 58 dmd = self.context.zport.dmd 59 for key, value in kwargs.iteritems(): 60 if hasattr(dmd, key): 61 setattr(dmd, key, value) 62 63 return DirectResponse.succeed()
64