Package twisted :: Package web :: Package woven :: Module model :: Class Model

[show private | hide private]
[frames | no frames]

## Class Model

Known Subclasses:
  `MethodModel`, `Wrapper`, `AttributeModel`, `Page`, `LivePage`

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)`
| `__cmp__(self, other)`
| `__getstate__(self)`
| `addSubview(self, name, subview)`
| ``addView`(self, view)` Add a view for the model to keep track of.
| `getData(self)`
| ``getSubmodel`(self, 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.
| ``lookupSubmodel`(self, 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, data)`
| ``setSubmodel`(self, name, value)` Set a submodel on this model.
| ``submodelCheck`(self, name)` Check if a submodel name is allowed.
| `submodelFactory(self, name)`

Class Variable Summary
`list` | `allowed_names`
`class` | `IModel`
`list` | `protected_names`

Method Details

### addView(self, view)

Add a view for the model to keep track of.

### getSubmodel(self, 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.

### lookupSubmodel(self, 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, name, value)

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, name)

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

Class Variable Details

### allowed_names

  Type:
    `list`
  Value:

        []

### IModel

`IModel` = `twisted.web.woven.interfaces.IModel`

### protected_names

  Type:
    `list`
  Value:

        ['initialize',
         'addView',
         'addSubview',
         'removeView',
         'notify',
         'getSubmodel',
         'setSubmodel',
         'getData',
        ...

Generated by Epydoc 1.1 on Sat Feb 15 21:18:19 2003 | http://epydoc.sf.net