Example #1
0
 def __init__(self,
              id,
              sid,
              tid,
              relationship=FOLDERISH_REFERENCE,
              **kwargs):
     Reference.__init__(self, id, sid, tid, relationship, **kwargs)
 def __init__(self, id, sid, tid,
              relationship=FOLDERISH_REFERENCE, **kwargs):
     Reference.__init__(self, id, sid, tid, relationship, **kwargs)
Example #3
0
    return aggr


class ReferenceWithBrains(Reference):
    __implements__ = interfaces.IReferenceWithBrains


# These proxy methods all make use of a volatile attribute to store their value
# The dict maps method names, e.g. 'getSourceBrain', to functions that produce
# the value.
proxies = {
    'getSourceBrain':
    lambda self: brain.makeBrainAggregate(self, self.sourceUID),
    'getTargetBrain':
    lambda self: brain.makeBrainAggregate(self, self.targetUID),
    'getSourceObject': lambda self: Reference.getSourceObject(self),
    'getTargetObject': lambda self: Reference.getTargetObject(self),
}


def makeProxyMethod(key, valueFun):
    def proxyMethod(self):
        attr_name = '_v_%s' % key
        if not shasattr(self, attr_name):
            setattr(self, attr_name, valueFun(self))
        return getattr(self, attr_name)

    return proxyMethod


for key, valueFun in proxies.items():
Example #4
0
    classImplements(ReferenceWithBrains, IReferenceWithBrains)
except TypeError:
    ReferenceWithBrains.__implements__ = (IReferenceWithBrains,)

# # These proxy methods all make use of a volatile attribute to store their value
# The dict maps method names, e.g. 'getSourceBrain', to functions that produce
# the value.
proxies = {
    'getSourceBrain':
    lambda self: makeBrainAggregate(self, self.sourceUID),
           
    'getTargetBrain':
    lambda self: makeBrainAggregate(self, self.targetUID),

    'getSourceObject':
    lambda self: Reference.getSourceObject(self),

    'getTargetObject':
    lambda self: Reference.getTargetObject(self),
    }

def makeProxyMethod(key, valueFun):
    def proxyMethod(self):
        attr_name = '_v_%s' % key
        if not shasattr(self, attr_name):
            setattr(self, attr_name, valueFun(self))
        return getattr(self, attr_name)
    return proxyMethod

for key, valueFun in proxies.items():
    setattr(ReferenceWithBrains, key, makeProxyMethod(key, valueFun))