Ejemplo n.º 1
0
 def __add__(self, other):
     if ICollection.providedBy(other):
         copy = self.copy()
         for component in other:
             copy.append(component)
         return copy
     if IComponent.providedBy(other):
         copy = self.copy()
         copy.append(other)
         return copy
     raise NotImplementedError
Ejemplo n.º 2
0
 def extend(self, *components):
     for cmp in components:
         if self.type.providedBy(cmp):
             self.append(cmp)
         elif ICollection.providedBy(cmp):
             for item in cmp:
                 self.append(item)
         else:
             if self.factory is not None:
                 loadComponents()
                 factory = self.factory(cmp, default=None)
                 if factory is not None:
                     for item in factory.produce():
                         self.append(item)
                     continue
             raise TypeError(u'Invalid type', cmp)