Back to index

plone3  3.1.7
Functions | Variables
PlonePAS.patch Namespace Reference

Functions

def call
def isWrapperMethod
def wrap_method
def unwrap_method

Variables

tuple logger = logging.getLogger('Plone')
string PATTERN = '__PlonePAS_%s__'
string WRAPPER = '__PlonePAS_is_wrapper_method__'
string ORIG_NAME = '__PlonePAS_original_method_name__'

Function Documentation

def PlonePAS.patch.call (   self,
  __name__,
  args,
  kw 
)

Definition at line 23 of file patch.py.

00023 
00024 def call(self, __name__, *args, **kw):
00025     return getattr(self, PATTERN % __name__)(*args, **kw)

Here is the caller graph for this function:

Definition at line 28 of file patch.py.

00028 
00029 def isWrapperMethod(meth):
00030     return getattr(meth, WRAPPER, False)

Here is the caller graph for this function:

def PlonePAS.patch.unwrap_method (   klass,
  name 
)

Definition at line 45 of file patch.py.

00045 
00046 def unwrap_method(klass, name):
00047     old_method = getattr(klass, name)
00048     if not isWrapperMethod(old_method):
00049         raise ValueError, ('Trying to unwrap non-wrapped '
00050                            'method at %s.%s' % (klass.__name__, name))
00051     orig_name = getattr(old_method, ORIG_NAME)
00052     new_method = getattr(klass, orig_name)
00053     delattr(klass, orig_name)
00054     setattr(klass, name, new_method)

Here is the call graph for this function:

def PlonePAS.patch.wrap_method (   klass,
  name,
  method,
  pattern = PATTERN 
)

Definition at line 31 of file patch.py.

00031 
00032 def wrap_method(klass, name, method, pattern=PATTERN):
00033     old_method = getattr(klass, name)
00034     if isWrapperMethod(old_method):
00035         logger.info('PlonePAS: *NOT* wrapping already wrapped method at %s.%s',
00036             klass.__name__, name)
00037         return
00038     else:
00039         logger.info('PlonePAS: Wrapping method at %s.%s', klass.__name__, name)
00040     new_name = pattern % name
00041     setattr(klass, new_name, old_method)
00042     setattr(method, ORIG_NAME, new_name)
00043     setattr(method, WRAPPER, True)
00044     setattr(klass, name, method)

Here is the call graph for this function:


Variable Documentation

tuple PlonePAS.patch.logger = logging.getLogger('Plone')

Definition at line 19 of file patch.py.

string PlonePAS.patch.ORIG_NAME = '__PlonePAS_original_method_name__'

Definition at line 27 of file patch.py.

string PlonePAS.patch.PATTERN = '__PlonePAS_%s__'

Definition at line 22 of file patch.py.

string PlonePAS.patch.WRAPPER = '__PlonePAS_is_wrapper_method__'

Definition at line 26 of file patch.py.