Ejemplo n.º 1
0
 def length(self):
     # I strongly recommend to reimplement this in your subclass
     try:
         enumerable = IEnumerableMapping(self.context)
     except TypeError:
         return u''
     return len(enumerable)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 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")
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 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