Package topo :: Package misc :: Module legacy
[hide private]
[frames] | no frames]

Module legacy

source code

Code used to support old snapshots, and update scripts.

$Id: legacy.py 9315 2008-09-26 22:29:40Z ceball $


Version: $Revision: 8021 $

Classes [hide private]
  SnapshotSupport
Functions [hide private]
 
preprocess_state(class_, state_mod_fn)
Allow processing of state with state_mod_fn before class_.__setstate__(instance,state) is called.
source code
 
select_setstate(class_, selector, pre_super=False, post_super=True)
Select appropriate function to call as a replacement for class.__setstate__ at runtime.
source code
 
fake_a_class(module, old_name, new_class, new_class_args=())
Install a class named 'old_name' in 'module'; when created, the class actually returns an instance of 'new_class'.
source code
 
fake_a_package(old, new, add_what) source code
 
fake_a_module(name, parent, source_code, parent_path=None)
Create the module parent.name using source_code.
source code
 
LegacySupport()
Support for running old scripts.
source code
 
install_legacy_support() source code
Function Details [hide private]

select_setstate(class_, selector, pre_super=False, post_super=True)

source code 

Select appropriate function to call as a replacement
for class.__setstate__ at runtime.

selector must return None if the class_'s original method is
to be used; otherwise, it should return a function that takes
an instance of the class and the state.

pre_super and post_super determine if super(class_)'s
__setstate__ should be invoked before or after (respectively)
calling the function returned by selector. If selector returns
None, super(class_)'s __setstate__ is never called.

fake_a_class(module, old_name, new_class, new_class_args=())

source code 

Install a class named 'old_name' in 'module'; when created, the class actually returns an instance of 'new_class'.

new_class_args allow any arguments to be supplied to new_class before other arguments are passed at creation time.

LegacySupport()

source code 
Support for running old scripts. Use in conjunction with SnapshotSupport.install() to avoid duplication.