Exemple #1
0
    def render(self):
        """Creates a global function in JavaScript that returns the
        json encoding of all the permissions available to the current
        user in the current context.  The permissions will be in the
        form of a dictionary.
        """
        self._setAuthorizationCookie()
        permissions = self.permissionsForCurrentContext()
        managedObjectGuids = self.getManagedObjectGuids(
            returnChildrenForRootObj=True)
        data = json(permissions)
        func = """
<script type="text/javascript">
    function _global_permissions(){
        return %s;
    }

    function _managed_objects(){
        return %s;
    }

    function _has_global_roles() {
        return %s
    }
</script>
        """ % (data, json(managedObjectGuids), str(
            self.hasGlobalRoles()).lower())
        return func
    def render(self):
        """Creates a global function in JavaScript that returns the
        json encoding of all the permissions available to the current
        user in the current context.  The permissions will be in the
        form of a dictionary.
        """
        permissions = self.permissionsForCurrentContext()
        managedObjectGuids = self.getManagedObjectGuids()
        data = json(permissions)
        func = """
<script type="text/javascript">
    function _global_permissions(){
        return %s;
    }

    function _managed_objects(){
        return %s;
    }

    function _has_global_roles() {
        return %s
    }
</script>
        """ % (
            data,
            json(managedObjectGuids),
            str(self.hasGlobalRoles()).lower(),
        )
        return func
Exemple #3
0
 def getValues(self, keys=None, node=None):
     node = node or self.root
     values = {}
     if keys is None:
         keys = self.getKeys(node)
     for attr in keys:
         val = getattr(node, attr)
         try:
             json(val)
         except TypeError:
             # We can't deal with it, just move on
             continue
         values[attr] = val
     return values
Exemple #4
0
 def getValues(self, keys=None, node=None):
     node = node or self.root
     values = {}
     if keys is None:
         keys = self.getKeys(node)
     for attr in keys:
         val = getattr(node, attr)
         try:
             json(val)
         except TypeError:
             # We can't deal with it, just move on
             continue
         values[attr] = val
     return values
Exemple #5
0
 def render_jsonapi(self):
     """
     Generate an Ext.Direct provider definition for the python client
     """
     config = self._jsonapi_config()
     source = json(config)
     return source
 def render_jsonapi(self):
     """
     Generate an Ext.Direct provider definition for the python client
     """
     config = self._jsonapi_config()
     source = json(config)
     return source
Exemple #7
0
 def render(self):
     """
     Generate and return an Ext.Direct provider definition, wrapped in a
     <script> tag and ready for inclusion in an HTML document.
     """
     config = self._extdirect_config()
     source = "\nExt.Direct.addProvider(%s);\n" % json(config)
     return source.strip()
 def render(self):
     """
     Generate and return an Ext.Direct provider definition, wrapped in a
     <script> tag and ready for inclusion in an HTML document.
     """
     config = self._extdirect_config()
     source = "\nExt.Direct.addProvider(%s);\n" % json(config)
     return source.strip()
def manage_removeRemoteMonitors(self, ids=None, submon="", REQUEST=None):
    "Remove an object from this one"
    if REQUEST:
        REQUEST["data"] = json({"uids": ids, "command": "remove"})
        UpdateRemoteCollectorView(self, REQUEST)()
        messaging.IMessageSender(self).sendToBrowser(
            "Remote Collectors Deleted", "Deleted remote collectors: %s" % (", ".join(ids))
        )
        return self.callZenScreen(REQUEST)
def manage_removeRemoteMonitors(self, ids=None, submon="", REQUEST=None):
    'Remove an object from this one'
    if REQUEST:
        REQUEST['data'] = json({'uids': ids, 'command': 'remove'})
        UpdateRemoteCollectorView(self, REQUEST)()
        messaging.IMessageSender(self).sendToBrowser(
            'Remote Collectors Deleted',
            'Deleted remote collectors: %s' % (', '.join(ids)))
        return self.callZenScreen(REQUEST)
def manage_addRemoteMonitor(self, id=None, submon=None, REQUEST=None):
    'Add an object of sub_class, from a module of the same name'
    if REQUEST:
        REQUEST['data'] = json({'uids': [id], 'command': 'add'})
        UpdateRemoteCollectorView(self, REQUEST)()
        messaging.IMessageSender(self).sendToBrowser(
            'Remote Collector Created',
            'Remote collector %s was created.' % id)
        return self.callZenScreen(REQUEST)
def manage_addRemoteMonitor(self, id=None, submon=None, REQUEST=None):
    "Add an object of sub_class, from a module of the same name"
    if REQUEST:
        REQUEST["data"] = json({"uids": [id], "command": "add"})
        UpdateRemoteCollectorView(self, REQUEST)()
        messaging.IMessageSender(self).sendToBrowser(
            "Remote Collector Created", "Remote collector %s was created." % id
        )
        return self.callZenScreen(REQUEST)
Exemple #13
0
 def __call__(self):
     tpl = "Zenoss.i18n._data = %s;"
     # Get messages for general keys
     msgs = getDomainMessages('zenoss', self.request)
     # Add messages for the domain
     dname = self.request.get('domain')
     if dname:
         msgs.update(getDomainMessages(dname, self.request))
     self.request.response.setHeader('Content-Type', 'text/javascript')
     return tpl % json(msgs)
 def __call__(self):
     tpl = "Zenoss.i18n._data = %s;"
     # Get messages for general keys
     msgs = getDomainMessages('zenoss', self.request)
     # Add messages for the domain
     dname = self.request.get('domain')
     if dname:
         msgs.update(getDomainMessages(dname, self.request))
     self.request.response.setHeader('Content-Type', 'text/javascript')
     return tpl % json(msgs)
def manage_removeRemoteMonitors(self, ids=None, submon="", REQUEST=None):
    'Remove an object from this one'
    if REQUEST:
        REQUEST['data'] = json({'uids':ids, 'command':'remove'})
        UpdateRemoteCollectorView(self, REQUEST)()
        messaging.IMessageSender(self).sendToBrowser(
            'Remote Collectors Deleted',
            'Deleted remote collectors: %s' % (', '.join(ids))
        )
        return self.callZenScreen(REQUEST)
def manage_addRemoteMonitor(self, id=None, submon=None, REQUEST=None):
    'Add an object of sub_class, from a module of the same name'
    if REQUEST:
        REQUEST['data'] = json({'uids':[id], 'command':'add'})
        UpdateRemoteCollectorView(self, REQUEST)()
        messaging.IMessageSender(self).sendToBrowser(
            'Remote Collector Created',
            'Remote collector %s was created.' % id
        )
        return self.callZenScreen(REQUEST)
 def __call__(self):
     results = []
     viewname = self.request['HTTP_REFERER'].rsplit('/', 1)[-1]
     # incase there are query parameters in the url
     if "?" in viewname:
         viewname = viewname.split("?")[0]
     lang = negotiator.getLanguage(TooltipCatalog.langs(viewname),
                                   self.request)
     tips = TooltipCatalog.tips(viewname, lang)
     tpl = "Zenoss.registerTooltip(%s);"
     for tip in tips:
         results.append(tpl % json(tip))
     self.request.response.setHeader('Content-Type', 'text/javascript')
     self.request.response.enableHTTPCompression(REQUEST=self.request)
     return "Ext.onReady(function(){%s})" % '\n'.join(results)
 def __call__(self):
     results = []
     viewname = self.request['HTTP_REFERER'].rsplit('/', 1)[-1]
     # incase there are query parameters in the url
     if "?" in viewname:
         viewname = viewname.split("?")[0]
     lang = negotiator.getLanguage(TooltipCatalog.langs(viewname),
                                   self.request)
     tips = TooltipCatalog.tips(viewname, lang)
     tpl = "Zenoss.registerTooltip(%s);"
     for tip in tips:
         results.append(tpl % json(tip))
     self.request.response.setHeader('Content-Type', 'text/javascript')
     self.request.response.enableHTTPCompression(REQUEST=self.request)
     return "Ext.onReady(function(){%s})" % '\n'.join(results)
Exemple #19
0
 def __call__(self):
     results = []
     viewname = self.request['HTTP_REFERER'].rsplit('/', 1)[-1]
     # incase there are query parameters in the url
     if "?" in viewname:
         viewname = viewname.split("?")[0]
     lang = negotiator.getLanguage(TooltipCatalog.langs(viewname),
                                   self.request)
     tips = TooltipCatalog.tips(viewname, lang)
     tpl = "Zenoss.registerTooltip(%s);"
     for tip in tips:
         results.append(tpl % json(tip))
     # Bypass caching because all tooltips for all pages use the same file tooltips.js
     self.request.response.setHeader('Pragma', 'no-cache')
     self.request.response.setHeader('Cache-Control', 'no-cache')
     self.request.response.setHeader('Content-Type', 'text/javascript')
     return "Ext.onReady(function(){%s})" % '\n'.join(results)
Exemple #20
0
 def __call__(self):
     results = []
     viewname = self.request['HTTP_REFERER'].rsplit('/', 1)[-1]
     # incase there are query parameters in the url
     if "?" in viewname:
         viewname = viewname.split("?")[0]
     lang = negotiator.getLanguage(TooltipCatalog.langs(viewname),
                                   self.request)
     tips = TooltipCatalog.tips(viewname, lang)
     tpl = "Zenoss.registerTooltip(%s);"
     for tip in tips:
         results.append(tpl % json(tip))
     # Bypass caching because all tooltips for all pages use the same file tooltips.js
     self.request.response.setHeader('Pragma', 'no-cache')
     self.request.response.setHeader('Cache-Control', 'no-cache')
     self.request.response.setHeader('Content-Type', 'text/javascript')
     return "Ext.onReady(function(){%s})" % '\n'.join(results)