This module provides a variety of utility functions and classes used by the protocols package. None of them are really specific to the protocols package, and so may be useful to other libraries or applications.
callback [, depth=2]) |
The optional depth argument determines the number of frames between this function and the targeted class suite. depth defaults to 2, since this skips this function's frame and one calling function frame. If you use this function from a function called directly in the class suite, the default will be correct, otherwise you will need to determine the correct depth yourself.
This function works by installing a special class factory function in place of the __metaclass__ of the containing class. Therefore, only callbacks after the last __metaclass__ assignment in the containing class will be executed. Be sure that classes using ``advising'' functions declare any __metaclass__ first, to ensure all callbacks are run.
ob) |
frame) |
(kind,module,locals,globals)
tuple for
the supplied frame object. The returned kind is a string: either
``exec'', ``module'', ``class'', ``function call'', or ``unknown''.
module is the module object the frame is/was executed in, or
None if the frame's globals could not be correlated with a module in
sys.modules
. locals and globals are the frame's local
and global dictionaries, respectively. Note that they can be the same
dictionary, and that modifications to locals may not have any effect on the
execution of the frame.
This function is used by functions like addClassAdvisor() and advise() to verify where they're being called from, and to work their respective magics.
ob [, extendedClassic=False]) |
classicMRO(ob,extendedClassic)
. If ob is not a class
or type of any kind, a one-element sequence containing just ob is
returned.
ob [, extendedClassic=False]) |
bases [, explicit_mc=None]) |
classes) |
ob [, callable]) |
weakref.ref(ob,callable)
. Otherwise, returns a
StrongRef(ob)
, emulating the interface of weakref.ref()
.
This is used by code that wants to use weak references, but may be given
objects that are not weak-referenceable. Note that callable, if
supplied, will not be called if ob is not weak-referenceable.
ob) |