Imported modules
|
|
from __future__ import generators
from new import instancemethod
import sys
from types import ClassType, FunctionType, InstanceType
from weakref import ref
|
Functions
|
|
|
|
addClassAdvisor
|
addClassAdvisor ( callback, depth=2 )
Set up callback to be passed the containing class upon creation
This function is designed to be called by an "advising" function executed
in a class suite. The "advising" function supplies a callback that it
wishes to have executed when the containing class is created. The
callback will be given one argument: the newly created containing class.
The return value of the callback will be used in place of the class, so
the callback should return the input if it does not wish to replace the
class.
The optional depth argument to this function 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.
Exceptions
|
|
SyntaxError( "Advice must be in the body of a class statement" )
|
|
|
classicMRO
|
classicMRO ( ob, extendedClassic=False )
|
|
determineMetaclass
|
determineMetaclass ( bases, explicit_mc=None )
Determine metaclass from 1+ bases and optional explicit __metaclass__
Exceptions
|
|
TypeError( "Incompatible metatypes", bases )
|
|
|
getFrameInfo
|
getFrameInfo ( frame )
Return (kind,module,locals,globals) for a frame
kind is one of "exec", "module", "class", "function call", or "unknown".
|
|
getMRO
|
getMRO ( ob, extendedClassic=False )
|
|
isClassAdvisor
|
isClassAdvisor ( ob )
True if ob is a class advisor function
|
|
metamethod
|
metamethod ( func )
Wrapper for metaclass method that might be confused w/instance method
|
|
minimalBases
|
minimalBases ( classes )
Reduce a list of base classes to its ordered minimum equivalent
|
|
mkRef
|
mkRef ( ob, *args )
Return either a weakref or a StrongRef for ob
Note that extra args are forwarded to weakref.ref() if applicable.
|
|
supermeta
|
supermeta ( typ, ob )
Exceptions
|
|
TypeError( "Not sub/supertypes:", starttype, typ )
|
|
Classes
|
|
StrongRef |
Like a weakref, but for non-weakrefable objects
|
|