예제 #1
0
 def getter(self, data, enum):
     if not enum:
         return ProxyProperty(data)
     else:
         data = getattr(self._object, data, None)
         try:
             data = int(data)
             return Zuul.info(enum[data])
         except Exception:
             return Zuul.info(data)
예제 #2
0
    def test_Zuuldotinfo(self):
        isinfo = lambda x:isinstance(x, TargetInfo)

        single = Zuul.info(Target())
        alist = Zuul.info([Target(), Target()])
        adict = Zuul.info({'a':Target(), 'b':Target()})
        nested = Zuul.info([{'a':[Target()], 'b':Target()}])

        self.assert_(isinfo(single))
        self.assert_(isinstance(alist, list))
        for ob in alist:
            self.assert_(isinfo(ob))
        self.assert_(isinstance(adict, dict))
        for k, v in adict.items():
            self.assert_(isinfo(v))
        self.assert_(isinstance(nested, list))
예제 #3
0
    def test_Zuuldotinfo(self):
        isinfo = lambda x: isinstance(x, TargetInfo)

        single = Zuul.info(Target())
        alist = Zuul.info([Target(), Target()])
        adict = Zuul.info({'a': Target(), 'b': Target()})
        nested = Zuul.info([{'a': [Target()], 'b': Target()}])

        self.assert_(isinfo(single))
        self.assert_(isinstance(alist, list))
        for ob in alist:
            self.assert_(isinfo(ob))
        self.assert_(isinstance(adict, dict))
        for k, v in adict.items():
            self.assert_(isinfo(v))
        self.assert_(isinstance(nested, list))
예제 #4
0
 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
예제 #5
0
 def getter(self):
     return Zuul.info(getattr(self._object, relationship_name)())
예제 #6
0
 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'))
예제 #7
0
 def info(f, *args, **kwargs):
     result = f(*args, **kwargs)
     return Zuul.info(result, adapterName=adapterName)
예제 #8
0
def info(f, *args, **kwargs):
    """
    Apply Zuul.info to results.
    """
    result = f(*args, **kwargs)
    return Zuul.info(result)
예제 #9
0
 def info(f, *args, **kwargs):
     result = f(*args, **kwargs)
     return Zuul.info(result, adapterName=adapterName)
예제 #10
0
def info(f, *args, **kwargs):
    """
    Apply Zuul.info to results.
    """
    result = f(*args, **kwargs)
    return Zuul.info(result)
예제 #11
0
 def getter(self):
     return Zuul.info(getattr(self._object, relationship_name)())