Bases: tw.core.base.Widget
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Updates the dict sent to the template for the current request.
It is called when displaying or rendering a widget with all keyword arguments passed stuffed inside dict.
Widget subclasses can call super cooperatively to avoid boiler-plate code as Widget.update_params takes care of pre-populating this dict with all attributes from self listed at params (copying them if mutable) and preparing arguments for child widgets.
Any parameter sent to display or render will override those fetched from the instance or the class.
Any function listed at params which can be called without arguments will be automatically called to fetch fresh results on every request. Parameters not found either on the class, the instance or the keyword args to display or render will be set to None.
>>> class MyWidget(Widget):
... params = ["foo", "bar", "null"]
... foo = "foo"
...
>>> w = MyWidget('test', bar=lambda: "bar")
>>> d = {}
>>> w.update_params(d)
>>> d['bar']
'bar'
>>> d['foo']
'foo'
>>> d['null'] is None
True
>>> d = {'foo':'overriden'}
>>> w.update_params(d)
>>> d['foo']
'overriden'
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.forms.calendars.CalendarDatePicker
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Fetches values from the dict and inserts the in the attrs dict.
This is useful when you want to avoid boiler-place at the template:
Instead of:
<foo bar='$bar' zoo='$zoo' />
Do:
<foo py:attrs="attrs" />
And inside update_params:
self.update_attrs(d, 'bar', 'zoo')
(‘bar’ and ‘zoo’ need to be listed at params)
Validate value using validator if widget has one. If validation fails a formencode.Invalid exception will be raised.
If use_request_local is True and validation fails the exception and value will be placed at request local storage so if the widget is redisplayed in the same request error and value don’t have to be passed explicitly to display.
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.forms.calendars.CalendarDateTimePicker
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Fetches values from the dict and inserts the in the attrs dict.
This is useful when you want to avoid boiler-place at the template:
Instead of:
<foo bar='$bar' zoo='$zoo' />
Do:
<foo py:attrs="attrs" />
And inside update_params:
self.update_attrs(d, 'bar', 'zoo')
(‘bar’ and ‘zoo’ need to be listed at params)
Validate value using validator if widget has one. If validation fails a formencode.Invalid exception will be raised.
If use_request_local is True and validation fails the exception and value will be placed at request local storage so if the widget is redisplayed in the same request error and value don’t have to be passed explicitly to display.
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.forms.fields.InputField
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Fetches values from the dict and inserts the in the attrs dict.
This is useful when you want to avoid boiler-place at the template:
Instead of:
<foo bar='$bar' zoo='$zoo' />
Do:
<foo py:attrs="attrs" />
And inside update_params:
self.update_attrs(d, 'bar', 'zoo')
(‘bar’ and ‘zoo’ need to be listed at params)
Validate value using validator if widget has one. If validation fails a formencode.Invalid exception will be raised.
If use_request_local is True and validation fails the exception and value will be placed at request local storage so if the widget is redisplayed in the same request error and value don’t have to be passed explicitly to display.
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.forms.datagrid.DataGrid
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
Return Column with specified name.
Raises KeyError if no such column exists.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.forms.fields.TableForm
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Fetches values from the dict and inserts the in the attrs dict.
This is useful when you want to avoid boiler-place at the template:
Instead of:
<foo bar='$bar' zoo='$zoo' />
Do:
<foo py:attrs="attrs" />
And inside update_params:
self.update_attrs(d, 'bar', 'zoo')
(‘bar’ and ‘zoo’ need to be listed at params)
Validate value using validator if widget has one. If validation fails a formencode.Invalid exception will be raised.
If use_request_local is True and validation fails the exception and value will be placed at request local storage so if the widget is redisplayed in the same request error and value don’t have to be passed explicitly to display.
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.forms.calendars.CalendarDateTimePicker
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Fetches values from the dict and inserts the in the attrs dict.
This is useful when you want to avoid boiler-place at the template:
Instead of:
<foo bar='$bar' zoo='$zoo' />
Do:
<foo py:attrs="attrs" />
And inside update_params:
self.update_attrs(d, 'bar', 'zoo')
(‘bar’ and ‘zoo’ need to be listed at params)
Validate value using validator if widget has one. If validation fails a formencode.Invalid exception will be raised.
If use_request_local is True and validation fails the exception and value will be placed at request local storage so if the widget is redisplayed in the same request error and value don’t have to be passed explicitly to display.
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.core.base.Widget
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Updates the dict sent to the template for the current request.
It is called when displaying or rendering a widget with all keyword arguments passed stuffed inside dict.
Widget subclasses can call super cooperatively to avoid boiler-plate code as Widget.update_params takes care of pre-populating this dict with all attributes from self listed at params (copying them if mutable) and preparing arguments for child widgets.
Any parameter sent to display or render will override those fetched from the instance or the class.
Any function listed at params which can be called without arguments will be automatically called to fetch fresh results on every request. Parameters not found either on the class, the instance or the keyword args to display or render will be set to None.
>>> class MyWidget(Widget):
... params = ["foo", "bar", "null"]
... foo = "foo"
...
>>> w = MyWidget('test', bar=lambda: "bar")
>>> d = {}
>>> w.update_params(d)
>>> d['bar']
'bar'
>>> d['foo']
'foo'
>>> d['null'] is None
True
>>> d = {'foo':'overriden'}
>>> w.update_params(d)
>>> d['foo']
'overriden'
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.core.base.Widget
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Updates the dict sent to the template for the current request.
It is called when displaying or rendering a widget with all keyword arguments passed stuffed inside dict.
Widget subclasses can call super cooperatively to avoid boiler-plate code as Widget.update_params takes care of pre-populating this dict with all attributes from self listed at params (copying them if mutable) and preparing arguments for child widgets.
Any parameter sent to display or render will override those fetched from the instance or the class.
Any function listed at params which can be called without arguments will be automatically called to fetch fresh results on every request. Parameters not found either on the class, the instance or the keyword args to display or render will be set to None.
>>> class MyWidget(Widget):
... params = ["foo", "bar", "null"]
... foo = "foo"
...
>>> w = MyWidget('test', bar=lambda: "bar")
>>> d = {}
>>> w.update_params(d)
>>> d['bar']
'bar'
>>> d['foo']
'foo'
>>> d['null'] is None
True
>>> d = {'foo':'overriden'}
>>> w.update_params(d)
>>> d['foo']
'overriden'
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.core.base.Widget
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Updates the dict sent to the template for the current request.
It is called when displaying or rendering a widget with all keyword arguments passed stuffed inside dict.
Widget subclasses can call super cooperatively to avoid boiler-plate code as Widget.update_params takes care of pre-populating this dict with all attributes from self listed at params (copying them if mutable) and preparing arguments for child widgets.
Any parameter sent to display or render will override those fetched from the instance or the class.
Any function listed at params which can be called without arguments will be automatically called to fetch fresh results on every request. Parameters not found either on the class, the instance or the keyword args to display or render will be set to None.
>>> class MyWidget(Widget):
... params = ["foo", "bar", "null"]
... foo = "foo"
...
>>> w = MyWidget('test', bar=lambda: "bar")
>>> d = {}
>>> w.update_params(d)
>>> d['bar']
'bar'
>>> d['foo']
'foo'
>>> d['null'] is None
True
>>> d = {'foo':'overriden'}
>>> w.update_params(d)
>>> d['foo']
'overriden'
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.core.base.Widget
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Updates the dict sent to the template for the current request.
It is called when displaying or rendering a widget with all keyword arguments passed stuffed inside dict.
Widget subclasses can call super cooperatively to avoid boiler-plate code as Widget.update_params takes care of pre-populating this dict with all attributes from self listed at params (copying them if mutable) and preparing arguments for child widgets.
Any parameter sent to display or render will override those fetched from the instance or the class.
Any function listed at params which can be called without arguments will be automatically called to fetch fresh results on every request. Parameters not found either on the class, the instance or the keyword args to display or render will be set to None.
>>> class MyWidget(Widget):
... params = ["foo", "bar", "null"]
... foo = "foo"
...
>>> w = MyWidget('test', bar=lambda: "bar")
>>> d = {}
>>> w.update_params(d)
>>> d['bar']
'bar'
>>> d['foo']
'foo'
>>> d['null'] is None
True
>>> d = {'foo':'overriden'}
>>> w.update_params(d)
>>> d['foo']
'overriden'
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.forms.fields.MultipleSelectField, sprox.widgets.widgets.PropertyMixin
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Fetches values from the dict and inserts the in the attrs dict.
This is useful when you want to avoid boiler-place at the template:
Instead of:
<foo bar='$bar' zoo='$zoo' />
Do:
<foo py:attrs="attrs" />
And inside update_params:
self.update_attrs(d, 'bar', 'zoo')
(‘bar’ and ‘zoo’ need to be listed at params)
Validate value using validator if widget has one. If validation fails a formencode.Invalid exception will be raised.
If use_request_local is True and validation fails the exception and value will be placed at request local storage so if the widget is redisplayed in the same request error and value don’t have to be passed explicitly to display.
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.forms.fields.SingleSelectField, sprox.widgets.widgets.PropertyMixin
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Fetches values from the dict and inserts the in the attrs dict.
This is useful when you want to avoid boiler-place at the template:
Instead of:
<foo bar='$bar' zoo='$zoo' />
Do:
<foo py:attrs="attrs" />
And inside update_params:
self.update_attrs(d, 'bar', 'zoo')
(‘bar’ and ‘zoo’ need to be listed at params)
Validate value using validator if widget has one. If validation fails a formencode.Invalid exception will be raised.
If use_request_local is True and validation fails the exception and value will be placed at request local storage so if the widget is redisplayed in the same request error and value don’t have to be passed explicitly to display.
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.core.base.Widget
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Updates the dict sent to the template for the current request.
It is called when displaying or rendering a widget with all keyword arguments passed stuffed inside dict.
Widget subclasses can call super cooperatively to avoid boiler-plate code as Widget.update_params takes care of pre-populating this dict with all attributes from self listed at params (copying them if mutable) and preparing arguments for child widgets.
Any parameter sent to display or render will override those fetched from the instance or the class.
Any function listed at params which can be called without arguments will be automatically called to fetch fresh results on every request. Parameters not found either on the class, the instance or the keyword args to display or render will be set to None.
>>> class MyWidget(Widget):
... params = ["foo", "bar", "null"]
... foo = "foo"
...
>>> w = MyWidget('test', bar=lambda: "bar")
>>> d = {}
>>> w.update_params(d)
>>> d['bar']
'bar'
>>> d['foo']
'foo'
>>> d['null'] is None
True
>>> d = {'foo':'overriden'}
>>> w.update_params(d)
>>> d['foo']
'overriden'
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.core.base.Widget
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Updates the dict sent to the template for the current request.
It is called when displaying or rendering a widget with all keyword arguments passed stuffed inside dict.
Widget subclasses can call super cooperatively to avoid boiler-plate code as Widget.update_params takes care of pre-populating this dict with all attributes from self listed at params (copying them if mutable) and preparing arguments for child widgets.
Any parameter sent to display or render will override those fetched from the instance or the class.
Any function listed at params which can be called without arguments will be automatically called to fetch fresh results on every request. Parameters not found either on the class, the instance or the keyword args to display or render will be set to None.
>>> class MyWidget(Widget):
... params = ["foo", "bar", "null"]
... foo = "foo"
...
>>> w = MyWidget('test', bar=lambda: "bar")
>>> d = {}
>>> w.update_params(d)
>>> d['bar']
'bar'
>>> d['foo']
'foo'
>>> d['null'] is None
True
>>> d = {'foo':'overriden'}
>>> w.update_params(d)
>>> d['foo']
'overriden'
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.core.base.Widget
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Updates the dict sent to the template for the current request.
It is called when displaying or rendering a widget with all keyword arguments passed stuffed inside dict.
Widget subclasses can call super cooperatively to avoid boiler-plate code as Widget.update_params takes care of pre-populating this dict with all attributes from self listed at params (copying them if mutable) and preparing arguments for child widgets.
Any parameter sent to display or render will override those fetched from the instance or the class.
Any function listed at params which can be called without arguments will be automatically called to fetch fresh results on every request. Parameters not found either on the class, the instance or the keyword args to display or render will be set to None.
>>> class MyWidget(Widget):
... params = ["foo", "bar", "null"]
... foo = "foo"
...
>>> w = MyWidget('test', bar=lambda: "bar")
>>> d = {}
>>> w.update_params(d)
>>> d['bar']
'bar'
>>> d['foo']
'foo'
>>> d['null'] is None
True
>>> d = {'foo':'overriden'}
>>> w.update_params(d)
>>> d['foo']
'overriden'
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''
Bases: tw.core.base.Widget
Renders a widget and adapts the output. This method must be used to display child widgets inside their parent’s template so output is adapted.
Unlike tw.api.Widget.render(), tw.api.Widget.display() returns adapted output compatible with the template the widget is being rendered on. For example, this is needed so Genshi doesn’t autoescape string output from mako and to serialize Genshi output on the other way around.
The calculated id of the widget. This string will provide a unique id for each widget in the tree in a format which allows to re-recreate the nested structure. Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.id
'A_B_C'
Returns an iterator for all children applying a filter to them.
>>> class Widgets(WidgetsList):
... aa = Widget()
... ab = Widget()
... ba = Widget()
... bb = Widget()
...
>>> w = Widget(children=Widgets)
>>> [c.id for c in w.ifilter_children(lambda w: w.id.startswith('a'))]
['aa', 'ab']
A string that can be used as a key to index the dictionary of parameters sent to the root widget so it reaches this widget when displaying.
Example:
>>> A = Widget("A", children=[
... Widget("B", children=[
... Widget("C")
... ])
... ])
...
>>> C = A.c.B.c.C
>>> C.key
'.B.C'
Register the resources required by this Widget with tw.framework for inclusion in the page.
This method is called whenever a Widget is rendered
Updates the dict sent to the template for the current request.
It is called when displaying or rendering a widget with all keyword arguments passed stuffed inside dict.
Widget subclasses can call super cooperatively to avoid boiler-plate code as Widget.update_params takes care of pre-populating this dict with all attributes from self listed at params (copying them if mutable) and preparing arguments for child widgets.
Any parameter sent to display or render will override those fetched from the instance or the class.
Any function listed at params which can be called without arguments will be automatically called to fetch fresh results on every request. Parameters not found either on the class, the instance or the keyword args to display or render will be set to None.
>>> class MyWidget(Widget):
... params = ["foo", "bar", "null"]
... foo = "foo"
...
>>> w = MyWidget('test', bar=lambda: "bar")
>>> d = {}
>>> w.update_params(d)
>>> d['bar']
'bar'
>>> d['foo']
'foo'
>>> d['null'] is None
True
>>> d = {'foo':'overriden'}
>>> w.update_params(d)
>>> d['foo']
'overriden'
Does a pre-order walk on widget tree rooted at self optionally applying a filter on them.
Example:
>>> W = Widget
>>> w = W('a', children=[W('b', children=[W('c')]), W('d')])
>>> ''.join(i._id for i in w.walk())
'abcd'
>>> ''.join(i._id for i in w.walk(lambda x: not x.is_root))
'bcd'
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c'))
'c'
Recursion can be prevented on children that not match filter.
>>> ''.join(i._id for i in w.walk(lambda x: x._id == 'c', False))
''