def isMapping(self): """Is the object observed a mapping? Mappings are those objects, which are dicts or provide IEnumerableMapping. """ if isinstance(self.obj, types.DictType): return True return IEnumerableMapping.providedBy(self.obj)
def __iter__(self): for key in self.context: try: yield self.aliaser and self.aliaser.alias(key) or key except KeyError: if IEnumerableMapping.providedBy(self.aliaser): # an enumerable aliaser whitelists, we skip non-listed keys continue # no whitelisting and a KeyError on our internal data: that's # bad! Most probably not triggered on _Node but a subclass raise RuntimeError(u"Inconsist internal node state")
def __iter__(_next, self): for key in _next(self): try: if self.aliaser: yield self.aliaser.alias(key) else: yield key except KeyError: if IEnumerableMapping.providedBy(self.aliaser): # an enumerable aliaser whitelists, we skip non-listed keys continue raise