Package twisted :: Package web :: Package woven :: Module model :: Class Model
[frames | no frames]

Class Model

Known Subclasses:
AttributeModel, MethodModel, Wrapper

A Model which keeps track of views which are looking at it in order to notify them when the model changes.
Method Summary
  __init__(self, *args, **kwargs)
  __getstate__(self)
  addSubview(self, name, subview)
  addView(self, view)
Add a view for the model to keep track of.
  dataWillChange(self)
  getData(self, request)
  getSubmodel(self, request, name)
Get the submodel `name' of this model.
  initialize(self, *args, **kwargs)
Hook for subclasses to initialize themselves without having to mess with the __init__ chain.
  invalidateCache(self)
Invalidate the cache for this object, so the next time getData is called, it's getter method is called again.
  lookupSubmodel(self, request, submodelName)
Look up a full submodel name.
  notify(self, changed)
Notify all views that something was changed on me.
  removeView(self, view)
Remove a view that the model no longer should keep track of.
  setData(self, request, data)
  setGetter(self, getter)
  setSetter(self, setter)
  setSubmodel(self, request, name, value)
Set a submodel on this model.
  submodelCheck(self, request, name)
Check if a submodel name is allowed.
  submodelFactory(self, request, name)

Class Variable Summary
class __implements__ = twisted.web.woven.interfaces.IModel
list allowed_names = []
list protected_names = ['initialize', 'addView', 'addSubview'...

Method Details

addView(self, view)

Add a view for the model to keep track of.

getSubmodel(self, request, name)

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.

initialize(self, *args, **kwargs)

Hook for subclasses to initialize themselves without having to mess with the __init__ chain.

invalidateCache(self)

Invalidate the cache for this object, so the next time getData is called, it's getter method is called again.

lookupSubmodel(self, request, submodelName)

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

notify(self, changed=None)

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.

removeView(self, view)

Remove a view that the model no longer should keep track of.

setSubmodel(self, request=None, name=None, value=None)

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.

submodelCheck(self, request, name)

Check if a submodel name is allowed. Subclass me to implement a name security policy.

Class Variable Details

allowed_names

Type:
list
Value:
[]                                                                     

protected_names

Type:
list
Value:
['initialize',
 'addView',
 'addSubview',
 'removeView',
 'notify',
 'getSubmodel',
 'setSubmodel',
 'getData',
...                                                                    

Generated by Epydoc 2.0 on Sat May 15 20:07:50 2004 http://epydoc.sf.net