Class v.c.g.s.m.PropertyMeta(type):

Part of vmc.contrib.gtkmvc.support.metaclass_base View In Hierarchy

Known subclasses: vmc.contrib.gtkmvc.support.metaclasses.ObservablePropertyMeta

This is a meta-class that provides auto-property support. The idea is to allow programmers to define some properties which will be automatically connected to auto-generated code which handles access to those properties. How can you use this meta-class? First, '__metaclass__ = PropertyMeta' must be class member of the class you want to make the automatic properties handling. Second, '__properties__' must be a map containing the properties names as keys, values will be initial values for properties. That's all: after the instantiation, your class will contain all properties you named inside '__properties__'. Each of them will be also associated to a couple of automatically-generated functions which get and set the property value inside a generated member variable. About names: suppose the property is called 'x'. The generated variable (which keeps the real value of the property x) is called _prop_x. The getter is called get_prop_x(self), and the setter is called 'set_prop_x(self, value)'.

Customization: The base implementation of getter is to return the value stored in the variable associated to the property. The setter simply sets its value. Programmers can override basic behaviour for getters or setters simply by defining their getters and setters (see at the names convention above). The customized function can lie everywhere in the user classes hierarchy. Every overrided function will not be generated by the metaclass.

To supply your own methods is good for few methods, but can result in a very unconfortable way for many methods. In this case you can extend the meta-class, and override methods get_[gs]etter_source with your implementation (this can be probably made better). An example is provided in meta-class PropertyMetaVerbose below.
Method __init__ class constructor
Method __msg__ if level is less or equal to VERBOSE_LEVEL, ths message will
Method __create_prop_accessors__ Private method that creates getter and setter, and the
Method check_value_change Checks whether the value of the property changed in type
Method create_value This is used to create a value to be assigned to a
Method get_getter_source This must be overrided if you need a different implementation.
Method get_setter_source This must be overrided if you need a different implementation.
def __init__(cls, name, bases, dict):
class constructor
def __msg__(cls, msg, level):
if level is less or equal to VERBOSE_LEVEL, ths message will be printed
def __create_prop_accessors__(cls, prop_name, default_val):
Private method that creates getter and setter, and the corresponding property
def __create_property(cls, name, default_val):
Undocumented
def check_value_change(cls, old, new):
Checks whether the value of the property changed in type or if the instance has been changed to a different instance. If true, a call to model._reset_property_notification should be called in order to re-register the new property instance or type
def create_value(cls, prop_name, val, model=None):
This is used to create a value to be assigned to a property. Depending on the type of the value, different values are created and returned. For example, for a list, a ListWrapper is created to wrap it, and returned for the assignment. model is different from model when the value is changed (a model exists). Otherwise, during property creation model is None
def get_getter_source(cls, getter_name, prop_name):
This must be overrided if you need a different implementation. Simply the generated implementation returns the variable name _prop_name
def get_setter_source(cls, setter_name, prop_name):
This must be overrided if you need a different implementation. Simply the generated implementation sets the variable _prop_name
API Documentation for vodafone-mobile-connect-card-driver-for-linux, generated by pydoctor at 2008-01-10 13:06:31.