Class k.m.Model:

Part of kiwi.model

known subclasses: kiwi.model.PickledModel

The Model is a mixin to be used by domain classes when attached to Proxies. It also provides autonotification of changes to the attached proxies. Note that if using setters, a specific call to notify_proxies() may be necessary; see the doc for __setattr__.
Function__init__Undocumented
Functionensure_init
Sets up the variables so the Model's getattr hook and proxy
Functiondisable_autonotify
disable automatic notification to proxies based on __setattr__.
Functionnotify_proxies
Notify proxies that an attribute value has changed.
Functionregister_proxy_for_attribute
Attach a proxy to an attribute. The proxy will be notified of
Functionunregister_proxy_for_attribute
Detach a proxy from an attribute.
Functionunregister_proxy
Deattach a proxy completely from the model
Functionflush_proxies
Removes all proxies attached to Model
Functionblock_proxy
Temporarily block a proxy from receiving any notification. See
Functionunblock_proxy
Re-enable notifications to a proxy
Function__setattr__
A special setattr hook that notifies the registered proxies that
def __init__(self):
Undocumented
def ensure_init(self):
Sets up the variables so the Model's getattr hook and proxy notification work properly.
def disable_autonotify(self):
disable automatic notification to proxies based on __setattr__. All changes to the model must be followed by a call to notify_proxies() to allow the proxies to notice the change.
def notify_proxies(self, attr):
Notify proxies that an attribute value has changed.
def register_proxy_for_attribute(self, attr, proxy):
Attach a proxy to an attribute. The proxy will be notified of changes to that particular attribute (my means of Proxy.notify()).
def unregister_proxy_for_attribute(self, attr, proxy):
Detach a proxy from an attribute.
def unregister_proxy(self, proxy):
Deattach a proxy completely from the model
def flush_proxies(self):
Removes all proxies attached to Model
def block_proxy(self, proxy):
Temporarily block a proxy from receiving any notification. See unblock_proxy()
def unblock_proxy(self, proxy):
Re-enable notifications to a proxy
def __setattr__(self, attr, value):

A special setattr hook that notifies the registered proxies that the model has changed. Work around it setting attributes directly to self.__dict__.

Note that setattr() assumes that the name of the attribute being changed and the proxy attribute are the same. If this is not the case (as may happen when using setters) you must call notify_proxies() manually from the subclass' setter.