Example #1
0
    def exportNotifications(self, notifications):
        configs = []
        junkColumns = ('id', 'newId', 'uid', 'inspector_type', 'meta_type')
        for notificationInfo in notifications:
            config = marshal(notificationInfo)
            for item in junkColumns:
                if item in config:
                    del config[item]

            contentsTab = self._extractNotificationContentInfo(config)
            del config['content']
            config.update(contentsTab)

            config['recipients'] = [r['label'] for r in config['recipients']]
            config['subscriptions'] = [x['name'] for x in config['subscriptions']]

            windows = []
            for window in notificationInfo._object.windows():
                winconfig = marshal(IInfo(window))
                for witem in ('meta_type', 'newId', 'id', 'inspector_type', 'uid'):
                    del winconfig[witem]
                windows.append(winconfig)
            config['windows'] =  windows

            configs.append(config)
        return configs
Example #2
0
    def exportNotifications(self, notifications):
        configs = []
        junkColumns = ('id', 'newId', 'uid', 'inspector_type', 'meta_type')
        for notificationInfo in notifications:
            config = marshal(notificationInfo)
            for item in junkColumns:
                if item in config:
                    del config[item]

            contentsTab = self._extractNotificationContentInfo(config)
            del config['content']
            config.update(contentsTab)

            config['recipients'] = [r['label'] for r in config['recipients']]
            config['subscriptions'] = [
                x['name'] for x in config['subscriptions']
            ]

            windows = []
            for window in notificationInfo._object.windows():
                winconfig = marshal(IInfo(window))
                for witem in ('meta_type', 'newId', 'id', 'inspector_type',
                              'uid'):
                    del winconfig[witem]
                windows.append(winconfig)
            config['windows'] = windows

            configs.append(config)
        return configs
Example #3
0
 def test_default_marshal(t):
     expected = {
         k: t.allfields[k]
         for k in JobRecordMarshaller._default_keys if k in t.allfields
     }
     serialized = marshal(t.record)
     t.assertDictEqual(expected, serialized)
Example #4
0
 def test_keyed_marshal(t):
     keys = ("uuid", "name", "description")
     expected = {
         "uuid": t.allfields["jobid"],
         "name": t.allfields["name"],
         "description": t.allfields["description"],
     }
     serialized = marshal(t.record, keys=keys)
     t.assertDictEqual(expected, serialized)
Example #5
0
    def executeScript(self, script, commit=False):
        try:
            results = {}
            exec(script, get_zendmd_globals(self.context), results)
        except Exception as e:
            return DirectResponse.fail(msg=str(e))

        results.pop("_", None)

        try:
            return DirectResponse.succeed(**marshal(info(results)))
        except Exception as e:
            return DirectResponse.fail(msg=str(e))
 def getter(self):
     try:
         result = Zuul.info(getattr(self._object, method_name)())
     except TypeError:
         # If not callable avoid the traceback and send the property
         result = Zuul.info(getattr(self._object, method_name))
     if entity:
         # rather than returning entire object(s), return just
         # the fields needed by the UI renderer for creating links.
         return marshal(result,
                        keys=('name', 'meta_type', 'class_label', 'uid'))
     else:
         if enum and isinstance(enum, dict):
             try:
                 return enum.get(int(result), 'Unknown')
             except Exception:
                 return result
         else:
             return result
 def getter(self):
     # rather than returning entire object(s), return just the fields
     # required by the UI renderer for creating links.
     return marshal(Zuul.info(getattr(self._object, relationship_name)()),
                    keys=('name', 'meta_type', 'class_label', 'uid'))