def wrap(cls,function,name): 
    ''' A method to add new wrapped functions to the classes.'''
    if not hasattr(function,'metaObser'):
      raise TypeError('function %s has no "metaObser" attribute'%str(function))
    meta=function.metaObser
    setattr(cls,name,Wrapper(cls,function,name))
    for obser in meta.hooks:
      if not hasattr(obser,'klass'):# checks on targets validity
        raise TypeError('The obser %s has no "klass" attribute'%str(obser))
      if not Obser in obser.klass.__mro__: # not pythonic
        raise TypeError('The target method class %s of method %s was  not derived from Obser'%(str(obser.klass),obser.__name__))
      if meta.fired:
        obser.klass.hooks[meta.after,meta.external].setdefault(obser.__name__,[]).append(((cls,name),meta.success))
      else:
        cls.hooks[meta.after,meta.external].setdefault(name,[]).append(((obser.klass,obser.__name__),meta.success))
 A method to add new wrapped functions to the classes.
recipes/Python/439359_Observer_pattern_method_calls_low_level/recipe-439359.py