def getFlattener(original): """Get a flattener function with signature (ctx, original) for the object original. """ if hasattr(original, '__class__'): klas = original.__class__ else: klas = type(original) fromInterfaces = compy.getInterfaces(klas) + [klas] for inter in fromInterfaces: adapter = _flatteners.get(inter, None) if adapter is not None: return adapter interQual = util.qual(inter) adapterQual = _lazy_flatteners.get(interQual, None) if adapterQual is not None: adapter = util.namedAny(adapterQual) registerFlattener(adapter, inter) del _lazy_flatteners[interQual] return adapter print "***", fromInterfaces
def getBindingNames(self, context): ## Todo: remove this getattr ifs = compy.getInterfaces(getattr(self, 'boundTo', self)) ifs = [ x for x in ifs if x is not IConfigurable and x is not TypedInterface ] bindingNames = [] self.bindingDict = bindingDict = {} for interface in ifs: ## TypedInterfaces have a __spec__ attribute which is a list of all Typed properties and ## autocallable methods for binding in getattr(interface, '__spec__', []): bindingDict[binding.name] = binding if binding.name not in bindingNames: bindingNames.append(binding.name) if compy.implements(binding.typedValue, IActionableType): acts = binding.typedValue.actions if acts is None: acts = [] for action in acts: bindingDict[action.name] = action return bindingNames
def getFlattener(original): """Get a flattener function with signature (ctx, original) for the object original. """ if hasattr(original, '__class__'): klas = original.__class__ else: klas = type(original) fromInterfaces = compy.getInterfaces(klas) + [klas] for inter in fromInterfaces: adapter = _flatteners.get(inter, None) if adapter is not None: return adapter interQual = util.qual(inter) adapterQual = _lazy_flatteners.get(interQual, None) if adapterQual is not None: adapter = util.namedAny(adapterQual) registerFlattener(adapter, inter) #for fromInter in fromInterfaces: # registerFlattener(adapter, fromInter) del _lazy_flatteners[interQual] return adapter print "***", fromInterfaces
def megaGetInterfaces(adapter): adrs = [qual(x) for x in compy.getInterfaces(adapter)] ## temporarily turn this off till we need it if False: #hasattr(adapter, '_adapterCache'): adrs.extend(adapter._adapterCache.keys()) return adrs