def RegisterUtility(utility_name, version_mapping=None):
 def MethodDecorator(utility_method, version):
  'Decorates a method in the utility class.'
  registry_name = (('%s/%s' % (utility_name, version)) if version else utility_name)
  @wraps(utility_method)
  def Wrapper(*args, **kwargs):
   with _UTILITY_LOCK:
    _utility_registry.Add(registry_name)
   return utility_method(*args, **kwargs)
  return Wrapper
 def ClassDecorator(cls):
  'Decorates a utility class.'
  for (name, method) in inspect.getmembers(cls, inspect.ismethod):
   if (not name.startswith('_')):
    if (not getattr(method, '__self__', None)):
     setattr(cls, name, MethodDecorator(method, (version_mapping.get(name) if version_mapping else None)))
  return cls
 return ClassDecorator

def RegisterUtility ( utility_name , version_mapping = None ) : def MethodDecorator ( utility_method , version ) : registry_name = ( ( '%s/%s' % ( utility_name , version ) ) if version else utility_name ) @ wraps ( utility_method ) def Wrapper ( * args , ** kwargs ) : with _UTILITY_LOCK : _utility_registry . Add ( registry_name ) return utility_method ( * args , ** kwargs ) return Wrapper def ClassDecorator ( cls ) : for ( name , method ) in inspect . getmembers ( cls , inspect . ismethod ) : if ( not name . startswith ( '_' ) ) : if ( not getattr ( method , '__self__' , None ) ) : setattr ( cls , name , MethodDecorator ( method , ( version_mapping . get ( name ) if version_mapping else None ) ) ) return cls return ClassDecorator
decorator that registers a class with the given utility name .