Skip to content

Instantly share code, notes, and snippets.

@cluther
Created July 6, 2011 16:51
Show Gist options
  • Save cluther/1067739 to your computer and use it in GitHub Desktop.
Save cluther/1067739 to your computer and use it in GitHub Desktop.
Changing Zenoss Permissions
import logging
log = logging.getLogger('zen.ZenPack')
import Globals
from AccessControl import ClassSecurityInfo
from Products.ZenModel.Location import Location
from Products.ZenModel.ZenPack import ZenPack as ZenPackBase
from Products.ZenModel.ZenossSecurity import ZEN_COMMON, ZEN_VIEW
from Products.ZenWidgets.ZenossPortlets import ZenossPortlets
Location.security = ClassSecurityInfo()
Location.security.declareProtected(ZEN_COMMON, 'getChildLinks')
Location.security.declareProtected(ZEN_COMMON, 'numMappableChildren')
Location.security.declareProtected(ZEN_COMMON, 'getGeomapData')
Location.security.declareProtected(ZEN_COMMON, 'getChildGeomapData')
Location.security.declareProtected(ZEN_COMMON, 'getSecondaryNodes')
Globals.InitializeClass(Location)
new_portlets = []
for portlet in ZenossPortlets.portlets:
portlet['permission'] = ZEN_COMMON
new_portlets.append(portlet)
ZenossPortlets.portlets = new_portlets
class ZenPack(ZenPackBase):
def install(self, app):
super(ZenPack, self).install(app)
self.allowAuthenticatedRender(app.zport.RenderServer)
self.updatePortletPermissions(app.zport.ZenPortletManager)
def allowAuthenticatedRender(self, renderServer):
log.info('Allowing any authenticated access to RenderServer')
renderServer.manage_permission(ZEN_VIEW, ['Authenticated'])
def updatePortletPermissions(self, portletManager):
log.info("Enabling common access to all portlets.")
for portlet in ZenossPortlets.portlets:
portletManager.register_portlet(**portlet)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment