def length(self): # I strongly recommend to reimplement this in your subclass try: enumerable = IEnumerableMapping(self.context) except TypeError: return u'' return len(enumerable)