Class v.c.g.a.b.Adapter(Observer):

Part of vmc.contrib.gtkmvc.adapters.basic View In Hierarchy

Known subclasses: vmc.contrib.gtkmvc.adapters.basic.UserClassAdapter

No class docstring
Method __init__ Creates a new adapter that handles setting of value of a
Method connect_widget Called when the widget is instantiated, and the adapter is
Method update_model Forces the property to be updated from the value hold by
Method update_widget Forces the widget to be updated from the property
def __init__(self, model, prop_name, prop_read=None, prop_write=None, value_error=None):

Creates a new adapter that handles setting of value of a model single model property when a corresponding widgets set is changed and viceversa when the property is also observable.

This class handles only assignments to properties. For other kinds of setting (e.g. user-defined classes used as observable properties, containers, etc.) use other types of Adapters derived from this class.

prop_name is the model's property name (as a string). It is possible to use a dotted notation to identify a property contained into a hierarchy of models. For example 'a.b.c' identifies property 'c' into model 'b' inside model 'a', where model 'a' is an attribute of given top level model. Last name must be an observable or non-observable attribute, and previous names (if specified) must all refer to instances of class Model. First name from the left must be the name of a model instance inside the given model.

prop_{write,read} are two optional functions that apply custom modifications to the value of the property before setting and reading it. Both take a value and must return a transformed value whose type must be compatible with the type of the property.

value_error can be a function (or a method) to be called when a ValueError exception occurs while trying to set a wrong value for the property inside the model. The function will receive: the adapter, the property name and the value coming from the widget that offended the model.
def connect_widget(self, wid, getter=None, setter=None, signal=None, arg=None, update=True):

Called when the widget is instantiated, and the adapter is ready to connect the widget and the property inside the observed model. arg is the (optional) argument that will be passed when connecting the signal.

getter and setter are the (optional) methods used for reading and writing the widget's value. When not specified, default getter and setter will be guessed by looking at the widget type the adapter will be connected with. Guessing is carried out by querying information specified into module 'adapters.default'.

Finally, if update is false, the widget will not be updated
def update_model(self):
Forces the property to be updated from the value hold by the widget. This method should be called directly by the user in very unusual coditions.
def update_widget(self):
Forces the widget to be updated from the property value. This method should be called directly by the user when the property is not observable, or in very unusual coditions.
def _connect_model(self, model):
Used internally to connect the property into the model, and register self as a value observer for that property
def _get_observer_src(self, prop_name):
This is the code for an value change observer
def _add_method(self, src):
Private service to add a new method to the instance, given method code
def _get_property(self):
Private method that returns the value currently stored into the property
def _set_property(self, val):
Private method that sets the value currently of the property.
def _read_property(self, *args):
Returns the (possibly transformed) value that is stored into the property
def _write_property(self, val, *args):
Sets the value of property. Given val is transformed accodingly to prop_write function when specified at construction-time. A try to cast the value to the property type is given.
def _read_widget(self):
Returns the value currently stored into the widget, after transforming it accordingly to possibly specified function.
def _write_widget(self, val):
Writes value into the widget. If specified, user setter is invoked.
def _cast_value(self, val, totype):
Casts given val to given totype. Raises TypeError if not able to cast.
def _on_wid_changed(self, wid):
Called when the widget is changed
def _on_prop_changed(self):
Called by the observation code, when the value in the observed property is changed
API Documentation for vodafone-mobile-connect-card-driver-for-linux, generated by pydoctor at 2008-01-10 13:06:31.