Package schrodinger :: Package tasks :: Module mappers :: Class MapperMixin
[hide private]
[frames] | no frames]

Class MapperMixin

object --+
         |
        MapperMixin

Mixin that can facilitate the use of parameters and mappers for storing the state of its subclasses.

Any data members that need to be mapped should be mapped within subclasses using the mapper instance variable.

By defining af2SettingsGetValue and af2SettingsSetValue, the subclass of this mixin can be set as a mapped object in SettingsParamMapper. In order to enable this functionality, subclasses must

  1. add any necessary mappings to the mapper instance variable
  2. Define the class variable model_class
Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature
 
addMappings(self, mappings)
A convenience method for applying many mappings at once to the mapper attribute.
model_class
af2SettingsGetValue(self)
Create a new model and assign it to this object; populate it with the values of the associated view objects and return it.
model_class
af2SettingsSetValue(self, value)
Replace the model instance of this object with the specified model, then update the values of associated view objects.

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

Class Variables [hide private]
  model_class = None
to be defined in subclasses.
Instance Variables [hide private]
  mapper
a AbstractParamMapper instance that can be used to keep track of data members of this mixin's subclasses.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

addMappings(self, mappings)

 

A convenience method for applying many mappings at once to the mapper attribute.

See AbstractParamMapper.addMapping for more information.

Parameters:
  • mappings (an iterable of 2-tuples, where each 2-tuple contains -a hashable object -parameters.Param) - an iterable of 2-tuples containing pairs of target objects and corresponding parameters.Param

af2SettingsGetValue(self)

 

Create a new model and assign it to this object; populate it with the values of the associated view objects and return it.

Expect to be called from settings.get_obj_value, which is called from mappings.SettingsParamMapper._getTargetValue.

Returns: model_class
parameter model instance containing up-to-date values from this object

af2SettingsSetValue(self, value)

 

Replace the model instance of this object with the specified model, then update the values of associated view objects.

Expect to be called from settings.set_obj_value, which is called from mappings.SettingsParamMapper._setTargetValue.

Parameters:
  • value - parameter model
Returns: model_class

Class Variable Details [hide private]

model_class

to be defined in subclasses. The model class that stores information about the subclass of this mixin (which can be though of as a "view").
Value:
None