Package topo :: Package param :: Module parameterized :: Class PicklableClassAttributes
[hide private]
[frames] | no frames]

Class PicklableClassAttributes

source code

object --+
         |
        PicklableClassAttributes

Supports pickling of Parameterized class attributes for a given module.

When requested to be pickled, stores a module's PO classes' attributes, and any given startup_commands. On unpickling, executes the startup commands and sets the class attributes.

Instance Methods [hide private]
 
__init__(self, module, exclusions=(), startup_commands=())
module: a module object, such as topo
source code
 
__getstate__(self)
Return a dictionary of self.module's PO classes' attributes, plus self.startup_commands.
source code
 
__setstate__(self, state)
Execute the startup commands and set class attributes.
source code
 
get_PO_class_attributes(self, module, class_attributes, processed_modules, exclude=())
Recursively search module and get attributes of Parameterized classes within it.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, module, exclusions=(), startup_commands=())
(Constructor)

source code 

module: a module object, such as topo

Any submodules listed by name in exclusions will not have their classes' attributes saved.

Overrides: object.__init__

get_PO_class_attributes(self, module, class_attributes, processed_modules, exclude=())

source code 

Recursively search module and get attributes of Parameterized classes within it.

class_attributes is a dictionary {module.path.and.Classname: state}, where state is the dictionary {attribute: value}.

Something is considered a module for our purposes if inspect says it's a module, and it defines __all__. We only search through modules listed in __all__.

Keeps a list of processed modules to avoid looking at the same one more than once (since e.g. __main__ contains __main__ contains __main__...)

Modules can be specifically excluded if listed in exclude.