def optionalcascade(cont_attr, item_attr, doc=''):
 def getter(self):
  if self._items:
   return getattr(self[0], item_attr)
  else:
   return getattr(self, cont_attr)
 def setter(self, value):
  setattr(self, cont_attr, value)
  for item in self:
   setattr(item, item_attr, value)
 return property(fget=getter, fset=setter, doc=doc)

def optionalcascade ( cont_attr , item_attr , doc = '' ) : def getter ( self ) : if self . _items : return getattr ( self [ 0 ] , item_attr ) else : return getattr ( self , cont_attr ) def setter ( self , value ) : setattr ( self , cont_attr , value ) for item in self : setattr ( item , item_attr , value ) return property ( fget = getter , fset = setter , doc = doc )
returns a getter property with a cascading setter .