t.w.w.v.View : class documentation

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

Known subclasses: twisted.web.woven.page.Page, twisted.web.woven.tapestry.TapestryView, twisted.web.woven.view.LiveView, twisted.web.woven.widgets.Widget

Implements interfaces: twisted.web.resource.IResource, twisted.web.woven.interfaces.IView

No class docstring
Method getChild Undocumented
Method getChildWithDefault No summary
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 setupAllStacks Undocumented
Method setUp Undocumented
Method setupViewStack Undocumented
Method importViewLibrary No summary
Method render No summary
Method getTemplate Override this if you want to have your subclass look up its template using a different method.
Method lookupTemplate No summary
Method handleDocument Handle the root node, and send the page if there are no outstanding callbacks when it returns.
Method handleOutstanding Undocumented
Method recurseChildren If this node has children, handle them.
Method dispatchResult Check a given result from handling a node and look up a NodeMutator adapter which will convert the result into a node and insert it into the DOM tree. Return the new node.
Method modelChanged Rerender this view, because our model has changed.
Method generate Allow a view to be used like a widget. Will look up the template file and return it in place of the incoming node.
Method setController Set the controller that this view is related to.
Method setNode Undocumented
Method setSubmodel Undocumented
Method getNodeModel Get the model object associated with this node. If this node has a model= attribute, call getSubmodel on the current model object. If not, return the top of the model stack.
Method getNodeController Get a controller object to handle this node. If the node has no controller= attribute, first check to see if there is an IController adapter for our model.
Method getSubview Get a sub-view from me.
Method getNodeView Undocumented
Method handleNode Undocumented
Method handleControllerResults Handle a deferred from a controller.
Method handleNewNode Undocumented
Method sendPage Check to see if handlers recorded any errors before sending the page
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 __setitem__ Undocumented
Method unlinkViews Undocumented
Method dispatchResultCallback Deal with a callback from a deferred, checking to see if it is ok to send the page yet or not.
Method renderFailure Undocumented
def getChild(self, path, request): (source)
Undocumented
def getChildWithDefault(self, path, request): (source)
Return a child with the given name for the given request. This is the external interface used by the Resource publishing machinery. If implementing IResource without subclassing Resource, it must be provided. However, if subclassing Resource, getChild overridden instead.
def __init__(self, m, templateFile=None, templateDirectory=None, template=None, controller=None, doneCallback=None, modelStack=None, viewStack=None, controllerStack=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 setupAllStacks(self): (source)
Undocumented
def setUp(self, request, d): (source)
Undocumented
def setupViewStack(self): (source)
Undocumented
def importViewLibrary(self, namespace): (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 render(self, request, doneCallback=None): (source)
Render a request. This is called on the leaf resource for a request. Render must return either a string, which will be sent to the browser as the HTML for the request, or server.NOT_DONE_YET. If NOT_DONE_YET is returned, at some point later (in a Deferred callback, usually) call request.write("<html>") to write data to the request, and request.finish() to send the data to the browser.
def getTemplate(self, request): (source)
Override this if you want to have your subclass look up its template using a different method.
def lookupTemplate(self, request): (source)
Use acquisition to look up the template named by self.templateFile, located anywhere above this object in the heirarchy, and use it as the template. The first time the template is used it is cached for speed.
def handleDocument(self, request, document): (source)
Handle the root node, and send the page if there are no outstanding callbacks when it returns.
def handleOutstanding(self, request): (source)
Undocumented
def recurseChildren(self, request, node): (source)
If this node has children, handle them.
def dispatchResult(self, request, node, result): (source)
Check a given result from handling a node and look up a NodeMutator adapter which will convert the result into a node and insert it into the DOM tree. Return the new node.
def modelChanged(self, changed): (source)
Rerender this view, because our model has changed.
def generate(self, request, node): (source)
Allow a view to be used like a widget. Will look up the template file and return it in place of the incoming node.
def setController(self, controller): (source)
Set the controller that this view is related to.
def setNode(self, node): (source)
Undocumented
def setSubmodel(self, name): (source)
Undocumented
def getNodeModel(self, request, node, submodel): (source)
Get the model object associated with this node. If this node has a model= attribute, call getSubmodel on the current model object. If not, return the top of the model stack.
def getNodeController(self, request, node, submodel, model): (source)
Get a controller object to handle this node. If the node has no controller= attribute, first check to see if there is an IController adapter for our model.
def getSubview(self, request, node, model, viewName): (source)
Get a sub-view from me.
Returnswidgets.Widget
def getNodeView(self, request, node, submodel, model): (source)
Undocumented
def handleNode(self, request, node): (source)
Undocumented
def handleControllerResults(self, controllerResult, request, node, controller, view): (source)
Handle a deferred from a controller.
def handleNewNode(self, request, returnNode): (source)
Undocumented
def sendPage(self, request): (source)
Check to see if handlers recorded any errors before sending the page
def setSubviewFactory(self, name, factory, *args, setup=None, **kwargs): (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 __setitem__(self, key, value): (source)
Undocumented
def unlinkViews(self): (source)
Undocumented
def dispatchResultCallback(self, result, request, node): (source)
Deal with a callback from a deferred, checking to see if it is ok to send the page yet or not.
def renderFailure(self, failure, request): (source)
Undocumented
API Documentation for Twisted, generated by pydoctor at 2011-10-27 15:57:47.