t.w.w.m.Model : class documentation

Part of twisted.web.woven.model View Source View In Hierarchy

Known subclasses: twisted.web.woven.model.AttributeModel, twisted.web.woven.model.MethodModel, twisted.web.woven.model.Wrapper

Implements interfaces: twisted.web.woven.interfaces.IModel

A Model which keeps track of views which are looking at it in order to notify them when the model changes.
Method __init__ Undocumented
Method __getstate__ Undocumented
Method invalidateCache Invalidate the cache for this object, so the next time getData is called, it's getter method is called again.
Method initialize Hook for subclasses to initialize themselves without having to mess with the __init__ chain.
Method addView Add a view for the model to keep track of.
Method addSubview Undocumented
Method removeView Remove a view that the model no longer should keep track of.
Method setGetter Undocumented
Method setSetter Undocumented
Method notify No summary
Method lookupSubmodel Look up a full submodel name. I will split on `/' and call getSubmodel on each element in the 'path'.
Method submodelCheck Check if a submodel name is allowed. Subclass me to implement a name security policy.
Method submodelFactory Undocumented
Method getSubmodel Get the submodel `name' of this model. If I ever return a Deferred, then I ought to check for cached values (created by setSubmodel) before doing a regular Deferred lookup.
Method setSubmodel No summary
Method dataWillChange Undocumented
Method getData Return the raw data contained by this Model object, if it is a wrapper. If not, return self.
Method setData No summary
def __init__(self, *args, **kwargs): (source)
Undocumented
def __getstate__(self): (source)
Undocumented
def invalidateCache(self): (source)
Invalidate the cache for this object, so the next time getData is called, it's getter method is called again.
def initialize(self, *args, **kwargs): (source)
Hook for subclasses to initialize themselves without having to mess with the __init__ chain.
def addView(self, view): (source)
Add a view for the model to keep track of.
def addSubview(self, name, subview): (source)
Undocumented
def removeView(self, view): (source)
Remove a view that the model no longer should keep track of.
def setGetter(self, getter): (source)
Undocumented
def setSetter(self, setter): (source)
Undocumented
def notify(self, changed=None): (source)
Notify all views that something was changed on me. Passing a dictionary of {'attribute': 'new value'} in changed will pass this dictionary to the view for increased performance. If you don't want to do this, don't, and just use the traditional MVC paradigm of querying the model for things you're interested in.
def lookupSubmodel(self, request, submodelName): (source)

Look up a full submodel name. I will split on `/' and call getSubmodel on each element in the 'path'.

Override me if you don't want 'traversing'-style lookup, but would rather like to look up a model based on the entire model name specified.

If you override me to return Deferreds, make sure I look up values in a cache (created by setSubmodel) before doing a regular Deferred lookup.

XXX: Move bits of this docstring to interfaces.py
def submodelCheck(self, request, name): (source)
Check if a submodel name is allowed. Subclass me to implement a name security policy.
def submodelFactory(self, request, name): (source)
Undocumented
def getSubmodel(self, request, name): (source)
Get the submodel `name' of this model. If I ever return a Deferred, then I ought to check for cached values (created by setSubmodel) before doing a regular Deferred lookup.
def setSubmodel(self, request=None, name=None, value=None): (source)
Set a submodel on this model. If getSubmodel or lookupSubmodel ever return a Deferred, I ought to set this in a place that lookupSubmodel/getSubmodel know about, so they can use it as a cache.
def dataWillChange(self): (source)
Undocumented
def getData(self, request): (source)
Return the raw data contained by this Model object, if it is a wrapper. If not, return self.
def setData(self, request, data): (source)
Set the raw data referenced by this Model object, if it is a wrapper. This is done by telling our Parent model to setSubmodel the new data. If this object is not a wrapper, keep the data around and return it for subsequent getData calls.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 16:02:37.