[Subversion] / RuleDispatch / src / dispatch / __init__.py  

Diff of /RuleDispatch/src/dispatch/__init__.py

Parent Directory | Revision Log

version 2716, Wed Mar 27 17:37:01 2013 UTC version 2717, Wed Mar 27 17:40:01 2013 UTC
Line 18 
Line 18 
   
 from dispatch.interfaces import *  from dispatch.interfaces import *
 from types import ClassType as _ClassType  from types import ClassType as _ClassType
   from peak.util.decorators import decorate as as_
   globals()['as'] = as_   # backward compatibility for Python < 2.6
   
 _cls  = _ClassType,type  _cls  = _ClassType,type
   
Line 37 
Line 39 
   
   
   
   
   
 def generic(combiner=None):  def generic(combiner=None):
     """Use the following function as the skeleton for a generic function      """Use the following function as the skeleton for a generic function
   
Line 94 
Line 94 
   
     return decorate_assignment(callback)      return decorate_assignment(callback)
   
 def as_(*decorators):  
     """Use Python 2.4 decorators w/Python 2.2+  
   
     Example:  
   
         import dispatch  
   
         class Foo(object):  
             [dispatch.as(classmethod)]  
             def something(cls,etc):  
                 \"""This is a classmethod\"""  
     """  
   
     if len(decorators)>1:  
         decorators = list(decorators)  
         decorators.reverse()  
   
     def callback(frame,k,v,old_locals):  
         for d in decorators:  
             v = d(v)  
         return v  
   
     from peak.util.decorators import decorate_assignment  
     return decorate_assignment(callback)  
   
 globals()['as'] = as_   # backward compatibility for Python < 2.6  
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
 def on(argument_name):  def on(argument_name):
     """Decorate the following function as a single-dispatch generic function      """Decorate the following function as a single-dispatch generic function


Generate output suitable for use with a patch program
Legend:
Removed from v.2716  
changed lines
  Added in v.2717

cvs-admin@eby-sarna.com

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help