t.w.w.i.IView(Interface) : interface documentation

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

Known implementations: twisted.web.woven.view.View

A MVC View
Method __init__ A view must be told what its model is, and may be told what its controller is, but can also look up its controller if none specified.
Method modelChanged Dispatch changed messages to any update_* methods which may have been defined, then pass the update notification on to the controller.
Method controllerFactory Hook for subclasses to customize the controller that is associated with the model associated with this view.
Method setController Set the controller that this view is related to.
Method importViewLibrary No summary
Method getSubview Look for a view named "viewName" to handle the node "node". When a node <div view="foo" /> is present in the template, this method will be called with viewName set to "foo".
Method setSubviewFactory Set the callable "factory", which takes a model and should return a Widget, to be called by the default implementation of getSubview when the viewName "name" is present in the template.
Method __adapt__ Undocumented
def __init__(model, controller=None): (source)
A view must be told what its model is, and may be told what its controller is, but can also look up its controller if none specified.
def modelChanged(changed): (source)
Dispatch changed messages to any update_* methods which may have been defined, then pass the update notification on to the controller.
def controllerFactory(): (source)

Hook for subclasses to customize the controller that is associated with the model associated with this view.

Default behavior: Look up a component that implements IController for the self.model instance.
def setController(controller): (source)
Set the controller that this view is related to.
def importViewLibrary(moduleOrObject): (source)
Import the given object or module into this View's view namespace stack. If the given object or module has a getSubview function or method, it will be called when a node has a view="foo" attribute. If no getSubview method is defined, a default one will be provided which looks for the literal name in the namespace.
def getSubview(request, node, model, viewName): (source)

Look for a view named "viewName" to handle the node "node". When a node <div view="foo" /> is present in the template, this method will be called with viewName set to "foo".

Return None if this View doesn't want to provide a Subview for the given name.
def setSubviewFactory(name, factory, setup=None): (source)

Set the callable "factory", which takes a model and should return a Widget, to be called by the default implementation of getSubview when the viewName "name" is present in the template.

This would generally be used like this:

view.setSubviewFactory("foo", MyFancyWidgetClass)

This is equivalent to:
   def wvfactory_foo(self, request, node, m):
       return MyFancyWidgetClass(m)

Which will cause an instance of MyFancyWidgetClass to be instanciated when template node <div view="foo" /> is encountered.

If setup is passed, it will be passed to new instances returned from this factory as a setup method. The setup method is called each time the Widget is generated. Setup methods take (request, widget, model) as arguments.

This is equivalent to:
   def wvupdate_foo(self, request, widget, model):
       # whatever you want
def __adapt__(adaptable, default): (source)
Undocumented
API Documentation for Twisted, generated by pydoctor at 2011-10-27 15:57:47.