Class t.w.w.w.Widget(view.View):

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

Known subclasses: twisted.web.woven.form.FormFillerWidget, twisted.web.woven.widgets.Anchor, twisted.web.woven.widgets.Attributes, twisted.web.woven.widgets.Bold, twisted.web.woven.widgets.Br, twisted.web.woven.widgets.Break, twisted.web.woven.widgets.Cell, twisted.web.woven.widgets.ColumnList, twisted.web.woven.widgets.DefaultWidget, twisted.web.woven.widgets.DeferredWidget, twisted.web.woven.widgets.Div, twisted.web.woven.widgets.Error, twisted.web.woven.widgets.ExpandMacro, twisted.web.woven.widgets.Image, twisted.web.woven.widgets.Input, twisted.web.woven.widgets.Link, twisted.web.woven.widgets.List, twisted.web.woven.widgets.Option, twisted.web.woven.widgets.ParagraphText, twisted.web.woven.widgets.RawText, twisted.web.woven.widgets.Row, twisted.web.woven.widgets.Span, twisted.web.woven.widgets.Table, twisted.web.woven.widgets.Text

A Widget wraps an object, its model, for display. The model can be a simple Python object (string, list, etc.) or it can be an instance of model.Model. (The former case is for interface purposes, so that the rest of the code does not have to treat simple objects differently from Model instances.)

If the model is-a Model, there are two possibilities:
Instance VariablesmodelIf the current model is an model.Model, then the result of model.getData(). Otherwise the original object itself.
Class VariablestagNameThe tag name of the element that this widget creates. If this is None, then the original Node will be cloned.
wantsAllNotificationsIndicate that this widget wants to recieve every change notification from the main model, not just notifications that affect its model.
Method __init__
Method _reset Undocumented
Method initialize Use this method instead of __init__ to initialize your Widget, so you
Method setSubmodel I use the submodel to know which attribute in self.model I am responsible for
Method getData I have a model; however since I am a widget I am only responsible
Method setData If the return value of getData is a Deferred, I am called
Method add Add `item' to the children of the resultant DOM Node of this widget.
Method appendChild Add `item' to the children of the resultant DOM Node of this widget.
Method insert Insert `item' at `index' in the children list of the resultant DOM Node
Method setNode Set a node for this widget to use instead of creating one programatically.
Method cleanNode Do your part, prevent infinite recursion!
Method generate Undocumented
Method _regenerate Undocumented
Method setDataCallback Undocumented
Method setUp Override this method to set up your Widget prior to generateDOM. This
Method generateDOM
Method modelChanged Undocumented
Method __setitem__ Convenience syntax for adding attributes to the resultant DOM Node of
Method __getitem__ Convenience syntax for getting an attribute from the resultant DOM Node
Method setError Convenience method for allowing a Controller to report an error to the
Method getTopModel Get a reference to this page's top model object.
Method getAllPatterns Get all nodes below this one which have a matching pattern attribute.
Method getPattern Get a named slot from the incoming template node. Returns a copy
Method addUpdateMethod Add a method to this widget that will be called when the widget
Method addEventHandler Add an event handler to this widget. eventName is a string
Method onEvent Dispatch a client-side event to an event handler that was
def __init__(self, *args, model=None, submodel=None, setup=None, controller=None, viewStack=None, **kwargs): (source)
Parametersmodel(type: interfaces.IModel )
submodelsee Widget.setSubmodel (type: String )
setup(type: Callable )
def _reset(self): (source)
Undocumented
def initialize(self, *args, **kwargs): (source)
Use this method instead of __init__ to initialize your Widget, so you don't have to deal with calling the __init__ of the superclass.
def setSubmodel(self, submodel): (source)
I use the submodel to know which attribute in self.model I am responsible for
def getData(self, request=None): (source)

I have a model; however since I am a widget I am only responsible for a portion of that model. This method returns the portion I am responsible for.

The return value of this may be a Deferred; if it is, then setData will be called once the result is available.
def setData(self, request=None, data=None): (source)
If the return value of getData is a Deferred, I am called when the result of the Deferred is available.
def add(self, item): (source)
Add `item' to the children of the resultant DOM Node of this widget.
Parametersitem(type: A DOM node or Widget. )
def appendChild(self, item): (source)
Add `item' to the children of the resultant DOM Node of this widget.
Parametersitem(type: A DOM node or Widget. )
def insert(self, index, item): (source)
Insert `item' at `index' in the children list of the resultant DOM Node of this widget.
Parametersitem(type: A DOM node or Widget. )
def setNode(self, node): (source)
Set a node for this widget to use instead of creating one programatically. Useful for looking up a node in a template and using that.
def cleanNode(self, node): (source)
Do your part, prevent infinite recursion!
def generate(self, request, node): (source)
Undocumented
def _regenerate(self, request, node, data): (source)
Undocumented
def setDataCallback(self, result, request, node): (source)
Undocumented
def setUp(self, request, node, data): (source)

Override this method to set up your Widget prior to generateDOM. This is a good place to call methods like add, insert, __setitem__ and __getitem__.

Overriding this method obsoletes overriding generateDOM directly, in most cases.
Parametersrequest(type: twisted.web.server.Request. )
nodeThe DOM node which this Widget is operating on.
dataThe Model data this Widget is meant to operate upon.
def generateDOM(self, request, node): (source)
ReturnsA DOM Node to replace the Node in the template that this Widget handles. This Node is created based on tagName, children, and attributes (You should populate these in setUp, probably).
def modelChanged(self, payload): (source)
Undocumented
def __setitem__(self, item, value): (source)
Convenience syntax for adding attributes to the resultant DOM Node of this widget.
def __getitem__(self, item): (source)
Convenience syntax for getting an attribute from the resultant DOM Node of this widget.
def setError(self, request, message): (source)
Convenience method for allowing a Controller to report an error to the user. When this is called, a Widget of class self.errorFactory is instanciated and set to self.become. When generate is subsequently called, self.become will be responsible for mutating the DOM instead of this widget.
def getTopModel(self): (source)
Get a reference to this page's top model object.
def getAllPatterns(self, name, default=missingPattern, clone=1, deep=1): (source)
Get all nodes below this one which have a matching pattern attribute.
def getPattern(self, name, default=missingPattern, clone=1, deep=1): (source)
Get a named slot from the incoming template node. Returns a copy of the node and all its children. If there was more than one node with the same slot identifier, they will be returned in a round-robin fashion.
def addUpdateMethod(self, updateMethod): (source)
Add a method to this widget that will be called when the widget is being rendered. The signature for this method should be updateMethod(request, widget, data) where widget will be the instance you are calling addUpdateMethod on.
def addEventHandler(self, eventName, handler, *args): (source)
Add an event handler to this widget. eventName is a string indicating which javascript event handler should cause this handler to fire. Handler is a callable that has the signature handler(request, widget, *args).
def onEvent(self, request, eventName, *args): (source)
Dispatch a client-side event to an event handler that was registered using addEventHandler.
API Documentation for twisted, generated by pydoctor.