sprox.widgets

Classes

class sprox.widgets.ContainerWidget(*args, **kw)

Bases: tw.core.base.Widget

adapt_value(value)

Adapt object value for rendering in this widget. Should return one of: * A list of objects for repeated widgets. * A dict for widgets with children, keyed by the children’s ids. * Any other object the widget understands.

add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

available_engines = []
children_deep
clone(*args, **kw)
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'toscawidgets'
get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
params = frozenset(['css_class', 'controller', 'id', 'css_classes'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)

This method is called for all tw.api.Widget base classes to perform final setup after the widget is initialized but before it is locked.

prepare_dict(value, d, adapt=True)

Prepares the all kw arguments sent to display or render before passing the kw argument’s dict to update_params.

register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

source_vars = frozenset([])
template = 'genshi:sprox.widgets.templates.container'
update_params(d)

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'
walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.SproxCalendarDatePicker(*args, **kw)

Bases: tw.forms.calendars.CalendarDatePicker

adapt_value(value)
add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

adjust_value(value, validator=None)

Adjusts the python value sent to InputWidget.display() with the validator so it can be rendered in the template.

attrs = {}
attrs__doc = 'Extra attributes for the outermost DOM node'
available_engines = ['mako', 'genshi']
button_text = 'Choose'
calendar_lang = 'en'
children_deep
clone(*args, **kw)
container_attrs = {}
container_attrs__doc = 'Extra attributes to include in the container tag around this widget'
css = [CSSLink(None, children=[], **{'modname': 'tw.forms', 'filename': 'static/calendar/calendar-system.css'})]
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
date_format = '%Y-%m-%d'
default = None
disabled = None
disabled__doc = "Should the field be disbaled on render and it's input ignored by the validator? UNIMPLEMENTED"
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'genshi'
error_at_request

Validation error for current request.

file_upload = False
force_conversion = False
generate_schema()

If the widget has children this method generates a Schema to validate including the validators from all children once these are all known.

Returns a CalendarLangFileLink containing a list of name patterns to try in turn to find the correct calendar locale file to use.

get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

help_text = None
help_text__doc = 'Description of the field to aid the user'
id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_required
is_required__doc = 'Computed flag indicating if input is required from this field'
is_root

True if the widget doesn’t have a parent

javascript = [JSLink(None, children=[], **{'modname': 'tw.forms', 'filename': 'static/calendar/calendar.js'}), JSLink(None, children=[], **{'modname': 'tw.forms', 'javascript': [JSLink(None, children=[], **{'modname': 'tw.forms', 'filename': 'static/calendar/calendar.js'})], 'filename': 'static/calendar/calendar-setup.js'})]
key

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'
label_text = None
label_text__doc = 'The text that should label this field'
name
name__doc = 'Name for this input Widget. This is the name of the variable that will reach the controller. This parameter can only be set during widget initialization'
name_path_elem
not_empty = True
params = frozenset(['label_text', 'suppress_label', 'strip_name', 'button_text', 'picker_shows_time', 'disabled', 'attrs', 'container_attrs', 'help_text', 'not_empty', 'id', 'date_format', 'style', 'name', 'css_class', 'calendar_lang', 'show_error', 'css_classes', 'tzinfo', 'is_required'])
parent = None
path

Iterates a walk from this widget to the root of the tree

picker_shows_time = False
post_init(*args, **kw)

Takes care of post-initialization of InputWidgets.

prepare_dict(value, kw, adapt=True)

Prepares the dict sent to the template with functions to access the children’s errors if any.

propagate_errors(parent_kw, parent_error)
register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

safe_validate(value)

Tries to coerce the value to python using the validator. If validation fails the original value will be returned unmodified.

show_error = False
show_error__doc = "Should the field display it's own errors? Defaults to False because normally they're displayed by the container widget"
source_vars = frozenset([])
strip_name = False
strip_name__doc = "If this flag is True then the name of this widget will not be included in the fully-qualified names of the widgets in this subtree. This is useful to 'flatten-out' nested structures. This parameter can only be set during initialization."
style = None
style__doc = "Style properties for the field. It's recommended to use css classes and stylesheets instead of this parameter"
suppress_label = False
suppress_label__doc = 'Allows individual widgets to suppress the attached label in their container'
template = 'tw.forms.templates.calendar'
update_attrs(d, *args)

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)

update_params(d)
validate(value, state=None, use_request_local=True)

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.

validator = None
value_at_request

Value being validated in current request.

walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.SproxCalendarDateTimePicker(*args, **kw)

Bases: tw.forms.calendars.CalendarDateTimePicker

adapt_value(value)
add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

adjust_value(value, validator=None)

Adjusts the python value sent to InputWidget.display() with the validator so it can be rendered in the template.

attrs = {}
attrs__doc = 'Extra attributes for the outermost DOM node'
available_engines = ['mako', 'genshi']
button_text = 'Choose'
calendar_lang = 'en'
children_deep
clone(*args, **kw)
container_attrs = {}
container_attrs__doc = 'Extra attributes to include in the container tag around this widget'
css = [CSSLink(None, children=[], **{'modname': 'tw.forms', 'filename': 'static/calendar/calendar-system.css'})]
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
date_format = '%Y-%m-%d %H:%M:%S'
default = None
disabled = None
disabled__doc = "Should the field be disbaled on render and it's input ignored by the validator? UNIMPLEMENTED"
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'genshi'
error_at_request

Validation error for current request.

file_upload = False
force_conversion = False
generate_schema()

If the widget has children this method generates a Schema to validate including the validators from all children once these are all known.

Returns a CalendarLangFileLink containing a list of name patterns to try in turn to find the correct calendar locale file to use.

get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

help_text = None
help_text__doc = 'Description of the field to aid the user'
id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_required
is_required__doc = 'Computed flag indicating if input is required from this field'
is_root

True if the widget doesn’t have a parent

javascript = [JSLink(None, children=[], **{'modname': 'tw.forms', 'filename': 'static/calendar/calendar.js'}), JSLink(None, children=[], **{'modname': 'tw.forms', 'javascript': [JSLink(None, children=[], **{'modname': 'tw.forms', 'filename': 'static/calendar/calendar.js'})], 'filename': 'static/calendar/calendar-setup.js'})]
key

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'
label_text = None
label_text__doc = 'The text that should label this field'
name
name__doc = 'Name for this input Widget. This is the name of the variable that will reach the controller. This parameter can only be set during widget initialization'
name_path_elem
not_empty = True
params = frozenset(['label_text', 'suppress_label', 'strip_name', 'button_text', 'picker_shows_time', 'disabled', 'attrs', 'container_attrs', 'help_text', 'not_empty', 'id', 'date_format', 'style', 'name', 'css_class', 'calendar_lang', 'show_error', 'css_classes', 'tzinfo', 'is_required'])
parent = None
path

Iterates a walk from this widget to the root of the tree

picker_shows_time = True
post_init(*args, **kw)

Takes care of post-initialization of InputWidgets.

prepare_dict(value, kw, adapt=True)

Prepares the dict sent to the template with functions to access the children’s errors if any.

propagate_errors(parent_kw, parent_error)
register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

safe_validate(value)

Tries to coerce the value to python using the validator. If validation fails the original value will be returned unmodified.

show_error = False
show_error__doc = "Should the field display it's own errors? Defaults to False because normally they're displayed by the container widget"
source_vars = frozenset([])
strip_name = False
strip_name__doc = "If this flag is True then the name of this widget will not be included in the fully-qualified names of the widgets in this subtree. This is useful to 'flatten-out' nested structures. This parameter can only be set during initialization."
style = None
style__doc = "Style properties for the field. It's recommended to use css classes and stylesheets instead of this parameter"
suppress_label = False
suppress_label__doc = 'Allows individual widgets to suppress the attached label in their container'
template = 'tw.forms.templates.calendar'
update_attrs(d, *args)

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)

update_params(d)
validate(value, state=None, use_request_local=True)

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.

validator = None
value_at_request

Value being validated in current request.

walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.SproxCheckBox(*args, **kw)

Bases: tw.forms.fields.InputField

adapt_value(value)
add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

adjust_value(value, validator=None)

Adjusts the python value sent to InputWidget.display() with the validator so it can be rendered in the template.

attrs = {}
attrs__doc = 'Extra attributes for the outermost DOM node'
available_engines = ['mako', 'genshi']
children_deep
clone(*args, **kw)
container_attrs = {}
container_attrs__doc = 'Extra attributes to include in the container tag around this widget'
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
disabled = None
disabled__doc = "Should the field be disbaled on render and it's input ignored by the validator? UNIMPLEMENTED"
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'genshi'
error_at_request

Validation error for current request.

file_upload = False
force_conversion = False
generate_schema()

If the widget has children this method generates a Schema to validate including the validators from all children once these are all known.

get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

help_text = None
help_text__doc = 'Description of the field to aid the user'
id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_required
is_required__doc = 'Computed flag indicating if input is required from this field'
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
label_text = None
label_text__doc = 'The text that should label this field'
name
name__doc = 'Name for this input Widget. This is the name of the variable that will reach the controller. This parameter can only be set during widget initialization'
name_path_elem
params = frozenset(['style', 'label_text', 'suppress_label', 'css_class', 'strip_name', 'container_attrs', 'disabled', 'attrs', 'show_error', 'css_classes', 'help_text', 'is_required', 'type', 'id', 'name'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)

Takes care of post-initialization of InputWidgets.

prepare_dict(value, kw, adapt=True)

Prepares the dict sent to the template with functions to access the children’s errors if any.

propagate_errors(parent_kw, parent_error)
register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

safe_validate(value)

Tries to coerce the value to python using the validator. If validation fails the original value will be returned unmodified.

show_error = False
show_error__doc = "Should the field display it's own errors? Defaults to False because normally they're displayed by the container widget"
source_vars = frozenset([])
strip_name = False
strip_name__doc = "If this flag is True then the name of this widget will not be included in the fully-qualified names of the widgets in this subtree. This is useful to 'flatten-out' nested structures. This parameter can only be set during initialization."
style = None
style__doc = "Style properties for the field. It's recommended to use css classes and stylesheets instead of this parameter"
suppress_label = False
suppress_label__doc = 'Allows individual widgets to suppress the attached label in their container'
template = 'sprox.widgets.templates.checkbox'
update_attrs(d, *args)

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)

update_params(d)
validate(value, state=None, use_request_local=True)

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.

validator

alias of StringBool

value_at_request

Value being validated in current request.

walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.SproxDataGrid(*args, **kw)

Bases: tw.forms.datagrid.DataGrid

adapt_value(value)

Adapt object value for rendering in this widget. Should return one of: * A list of objects for repeated widgets. * A dict for widgets with children, keyed by the children’s ids. * Any other object the widget understands.

add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

available_engines = ['mako', 'genshi']
children_deep
clone(*args, **kw)
css = [CSSLink(None, children=[], **{'modname': 'tw.forms', 'filename': 'static/grid.css'})]
css_class = 'grid'
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'genshi'
fields = []
get_column(name)

Return Column with specified name.

Raises KeyError if no such column exists.

get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

static get_field_getter(columns)

Return a function to access the fields of table by row, col.

id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
params = frozenset(['pks', 'controller', 'fields', 'css_class', 'css_classes', 'id', 'xml_fields'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)

This method is called for all tw.api.Widget base classes to perform final setup after the widget is initialized but before it is locked.

prepare_dict(value, d, adapt=True)

Prepares the all kw arguments sent to display or render before passing the kw argument’s dict to update_params.

register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

source_vars = frozenset([])
template = 'sprox.widgets.templates.datagrid'
update_params(d)
walk(filter=None, recur_if_filtered=True)

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))
''
xml_fields = ['actions']
class sprox.widgets.SproxTableForm(*args, **kw)

Bases: tw.forms.fields.TableForm

action = ''
action__doc = "The url where the form's contents should be submitted"
adapt_value(value)
add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

adjust_value(value, validator=None)

Adjusts the python value sent to InputWidget.display() with the validator so it can be rendered in the template.

attrs = {}
attrs__doc = 'Extra attributes for the outermost DOM node'
available_engines = ['mako', 'genshi']
children_deep
clone(*args, **kw)
container_attrs = {}
container_attrs__doc = 'Extra attributes to include in the container tag around this widget'
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
disabled = None
disabled__doc = "Should the field be disbaled on render and it's input ignored by the validator? UNIMPLEMENTED"
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'genshi'
error_at_request

Validation error for current request.

file_upload = False
force_conversion = False
generate_schema()

If the widget has children this method generates a Schema to validate including the validators from all children once these are all known.

get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

help_text = None
help_text__doc = 'Description of the field to aid the user'
hover_help = False
id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifields
ifilter_children(filter)

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']
ihidden_fields
is_required
is_required__doc = 'Computed flag indicating if input is required from this field'
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
label_text = None
label_text__doc = 'The text that should label this field'
method = 'post'
method__doc = 'The HTTP request method to be used'
name
name__doc = 'Name for this input Widget. This is the name of the variable that will reach the controller. This parameter can only be set during widget initialization'
name_path_elem
params = frozenset(['label_text', 'suppress_label', 'strip_name', 'show_children_errors', 'disabled', 'attrs', 'container_attrs', 'help_text', 'id', 'show_labels', 'submit_text', 'style', 'name', 'table_attrs', 'css_class', 'show_error', 'css_classes', 'action', 'is_required', 'method', 'hover_help'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)
prepare_dict(value, kw, adapt=True)

Prepares the dict sent to the template with functions to access the children’s errors if any.

propagate_errors(parent_kw, parent_error)
register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

safe_validate(value)

Tries to coerce the value to python using the validator. If validation fails the original value will be returned unmodified.

show_children_errors = True
show_error = False
show_error__doc = "Should the field display it's own errors? Defaults to False because normally they're displayed by the container widget"
show_labels = True
source_vars = frozenset([])
strip_name = False
strip_name__doc = "If this flag is True then the name of this widget will not be included in the fully-qualified names of the widgets in this subtree. This is useful to 'flatten-out' nested structures. This parameter can only be set during initialization."
style = None
style__doc = "Style properties for the field. It's recommended to use css classes and stylesheets instead of this parameter"
submit_label__doc = 'Label text for the auto-generated submit button. If empty then no label will be generated.'
submit_label_text = ''
submit_text = 'Submit'
submit_text__doc = 'Text that should appear in the auto-generated Submit button. If None then no submit button will be autogenerated.'
suppress_label = False
suppress_label__doc = 'Allows individual widgets to suppress the attached label in their container'
table_attrs = {}
template = 'sprox.widgets.templates.tableForm'
update_attrs(d, *args)

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)

update_params(d)
validate(value, state=None, use_request_local=True)

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.

validator = <Schema object 58 allow_extra_fields=True chained_validators=[] fields={} ignore_missing_keys=True pre_validators=[]>
value_at_request

Value being validated in current request.

walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.SproxTimePicker(*args, **kw)

Bases: tw.forms.calendars.CalendarDateTimePicker

adapt_value(value)
add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

adjust_value(value, validator=None)

Adjusts the python value sent to InputWidget.display() with the validator so it can be rendered in the template.

attrs = {}
attrs__doc = 'Extra attributes for the outermost DOM node'
available_engines = ['mako', 'genshi']
button_text = 'Choose'
calendar_lang = 'en'
children_deep
clone(*args, **kw)
container_attrs = {}
container_attrs__doc = 'Extra attributes to include in the container tag around this widget'
css = [CSSLink(None, children=[], **{'modname': 'tw.forms', 'filename': 'static/calendar/calendar-system.css'})]
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
date_format = '%H:%M:%S'
default = None
disabled = None
disabled__doc = "Should the field be disbaled on render and it's input ignored by the validator? UNIMPLEMENTED"
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'genshi'
error_at_request

Validation error for current request.

file_upload = False
force_conversion = False
generate_schema()

If the widget has children this method generates a Schema to validate including the validators from all children once these are all known.

Returns a CalendarLangFileLink containing a list of name patterns to try in turn to find the correct calendar locale file to use.

get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

help_text = None
help_text__doc = 'Description of the field to aid the user'
id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_required
is_required__doc = 'Computed flag indicating if input is required from this field'
is_root

True if the widget doesn’t have a parent

javascript = [JSLink(None, children=[], **{'modname': 'tw.forms', 'filename': 'static/calendar/calendar.js'}), JSLink(None, children=[], **{'modname': 'tw.forms', 'javascript': [JSLink(None, children=[], **{'modname': 'tw.forms', 'filename': 'static/calendar/calendar.js'})], 'filename': 'static/calendar/calendar-setup.js'})]
key

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'
label_text = None
label_text__doc = 'The text that should label this field'
name
name__doc = 'Name for this input Widget. This is the name of the variable that will reach the controller. This parameter can only be set during widget initialization'
name_path_elem
not_empty = True
params = frozenset(['label_text', 'suppress_label', 'strip_name', 'button_text', 'picker_shows_time', 'disabled', 'attrs', 'container_attrs', 'help_text', 'not_empty', 'id', 'date_format', 'style', 'name', 'css_class', 'calendar_lang', 'show_error', 'css_classes', 'tzinfo', 'is_required'])
parent = None
path

Iterates a walk from this widget to the root of the tree

picker_shows_time = True
post_init(*args, **kw)

Takes care of post-initialization of InputWidgets.

prepare_dict(value, kw, adapt=True)

Prepares the dict sent to the template with functions to access the children’s errors if any.

propagate_errors(parent_kw, parent_error)
register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

safe_validate(value)

Tries to coerce the value to python using the validator. If validation fails the original value will be returned unmodified.

show_error = False
show_error__doc = "Should the field display it's own errors? Defaults to False because normally they're displayed by the container widget"
source_vars = frozenset([])
strip_name = False
strip_name__doc = "If this flag is True then the name of this widget will not be included in the fully-qualified names of the widgets in this subtree. This is useful to 'flatten-out' nested structures. This parameter can only be set during initialization."
style = None
style__doc = "Style properties for the field. It's recommended to use css classes and stylesheets instead of this parameter"
suppress_label = False
suppress_label__doc = 'Allows individual widgets to suppress the attached label in their container'
template = 'tw.forms.templates.calendar'
update_attrs(d, *args)

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)

update_params(d)
validate(value, state=None, use_request_local=True)

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.

validator = None
value_at_request

Value being validated in current request.

walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.EntityDefWidget(*args, **kw)

Bases: tw.core.base.Widget

adapt_value(value)

Adapt object value for rendering in this widget. Should return one of: * A list of objects for repeated widgets. * A dict for widgets with children, keyed by the children’s ids. * Any other object the widget understands.

add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

available_engines = ['genshi']
children_deep
clone(*args, **kw)
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'toscawidgets'
get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
params = frozenset(['css_class', 'entity', 'id', 'css_classes'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)

This method is called for all tw.api.Widget base classes to perform final setup after the widget is initialized but before it is locked.

prepare_dict(value, d, adapt=True)

Prepares the all kw arguments sent to display or render before passing the kw argument’s dict to update_params.

register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

source_vars = frozenset([])
template = 'sprox.widgets.templates.entityDef'
update_params(d)

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'
walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.EntityLabelWidget(*args, **kw)

Bases: tw.core.base.Widget

adapt_value(value)

Adapt object value for rendering in this widget. Should return one of: * A list of objects for repeated widgets. * A dict for widgets with children, keyed by the children’s ids. * Any other object the widget understands.

add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

available_engines = []
children_deep
clone(*args, **kw)
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'toscawidgets'
get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
params = frozenset(['css_class', 'controller', 'entity', 'id', 'css_classes'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)

This method is called for all tw.api.Widget base classes to perform final setup after the widget is initialized but before it is locked.

prepare_dict(value, d, adapt=True)

Prepares the all kw arguments sent to display or render before passing the kw argument’s dict to update_params.

register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

source_vars = frozenset([])
template = 'genshi:sprox.widgets.templates.entityLabel'
update_params(d)

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'
walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.ModelLabelWidget(*args, **kw)

Bases: tw.core.base.Widget

adapt_value(value)

Adapt object value for rendering in this widget. Should return one of: * A list of objects for repeated widgets. * A dict for widgets with children, keyed by the children’s ids. * Any other object the widget understands.

add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

available_engines = ['mako', 'genshi']
children_deep
clone(*args, **kw)
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'toscawidgets'
get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
params = frozenset(['css_class', 'controller', 'identifier', 'id', 'css_classes'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)

This method is called for all tw.api.Widget base classes to perform final setup after the widget is initialized but before it is locked.

prepare_dict(value, d, adapt=True)

Prepares the all kw arguments sent to display or render before passing the kw argument’s dict to update_params.

register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

source_vars = frozenset([])
template = 'sprox.widgets.templates.modelLabel'
update_params(d)

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'
walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.PropertyMixin(*args, **kw)

Bases: tw.core.base.Widget

adapt_value(value)

Adapt object value for rendering in this widget. Should return one of: * A list of objects for repeated widgets. * A dict for widgets with children, keyed by the children’s ids. * Any other object the widget understands.

add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

available_engines = []
children_deep
clone(*args, **kw)
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'toscawidgets'
get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
params = frozenset(['dropdown_field_names', 'provider', 'css_class', 'css_classes', 'field_name', 'id', 'entity'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)

This method is called for all tw.api.Widget base classes to perform final setup after the widget is initialized but before it is locked.

prepare_dict(value, d, adapt=True)

Prepares the all kw arguments sent to display or render before passing the kw argument’s dict to update_params.

register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

source_vars = frozenset([])
template = None
update_params(d)

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'
walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.PropertyMultipleSelectField(*args, **kw)

Bases: tw.forms.fields.MultipleSelectField, sprox.widgets.widgets.PropertyMixin

adapt_value(value)
add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

adjust_value(value, validator=None)
attrs = {}
attrs__doc = 'Extra attributes for the outermost DOM node'
available_engines = ['mako', 'genshi']
children_deep
clone(*args, **kw)
container_attrs = {}
container_attrs__doc = 'Extra attributes to include in the container tag around this widget'
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
disabled = False
disabled__doc = "Should the field be disbaled on render and it's input ignored by the validator? UNIMPLEMENTED"
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'genshi'
error_at_request

Validation error for current request.

file_upload = False
force_conversion = False
generate_schema()

If the widget has children this method generates a Schema to validate including the validators from all children once these are all known.

get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

help_text = None
help_text__doc = 'Description of the field to aid the user'
id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_required
is_required__doc = 'Computed flag indicating if input is required from this field'
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
label_text = None
label_text__doc = 'The text that should label this field'
name
name__doc = 'Name for this input Widget. This is the name of the variable that will reach the controller. This parameter can only be set during widget initialization'
name_path_elem
options = []
params = frozenset(['label_text', 'suppress_label', 'strip_name', 'css_classes', 'entity', 'disabled', 'attrs', 'container_attrs', 'help_text', 'field_name', 'id', 'size', 'style', 'name', 'css_class', 'dropdown_field_names', 'show_error', 'provider', 'is_required', 'options'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)
prepare_dict(value, kw, adapt=True)

Prepares the dict sent to the template with functions to access the children’s errors if any.

propagate_errors(parent_kw, parent_error)
register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

safe_validate(value)

Tries to coerce the value to python using the validator. If validation fails the original value will be returned unmodified.

selected_verb = 'selected'
show_error = False
show_error__doc = "Should the field display it's own errors? Defaults to False because normally they're displayed by the container widget"
size = 5
source_vars = frozenset([])
strip_name = False
strip_name__doc = "If this flag is True then the name of this widget will not be included in the fully-qualified names of the widgets in this subtree. This is useful to 'flatten-out' nested structures. This parameter can only be set during initialization."
style = None
style__doc = "Style properties for the field. It's recommended to use css classes and stylesheets instead of this parameter"
suppress_label = False
suppress_label__doc = 'Allows individual widgets to suppress the attached label in their container'
template = 'tw.forms.templates.select_field'
update_attrs(d, *args)

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)

update_params(d)
validate(value, state=None, use_request_local=True)

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.

validator

alias of DefaultValidator

value_at_request

Value being validated in current request.

walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.PropertySingleSelectField(*args, **kw)

Bases: tw.forms.fields.SingleSelectField, sprox.widgets.widgets.PropertyMixin

adapt_value(value)
add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

adjust_value(value, validator=None)

Adjusts the python value sent to InputWidget.display() with the validator so it can be rendered in the template.

attrs = {}
attrs__doc = 'Extra attributes for the outermost DOM node'
available_engines = ['mako', 'genshi']
children_deep
clone(*args, **kw)
container_attrs = {}
container_attrs__doc = 'Extra attributes to include in the container tag around this widget'
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
disabled = False
disabled__doc = "Should the field be disbaled on render and it's input ignored by the validator? UNIMPLEMENTED"
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'genshi'
error_at_request

Validation error for current request.

file_upload = False
force_conversion = False
generate_schema()

If the widget has children this method generates a Schema to validate including the validators from all children once these are all known.

get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

help_text = None
help_text__doc = 'Description of the field to aid the user'
id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_required
is_required__doc = 'Computed flag indicating if input is required from this field'
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
label_text = None
label_text__doc = 'The text that should label this field'
name
name__doc = 'Name for this input Widget. This is the name of the variable that will reach the controller. This parameter can only be set during widget initialization'
name_path_elem
nullable = False
options = []
params = frozenset(['label_text', 'suppress_label', 'strip_name', 'css_classes', 'entity', 'disabled', 'attrs', 'container_attrs', 'help_text', 'field_name', 'id', 'style', 'name', 'nullable', 'css_class', 'dropdown_field_names', 'show_error', 'provider', 'is_required', 'options'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)

Takes care of post-initialization of InputWidgets.

prepare_dict(value, kw, adapt=True)

Prepares the dict sent to the template with functions to access the children’s errors if any.

propagate_errors(parent_kw, parent_error)
register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

safe_validate(value)

Tries to coerce the value to python using the validator. If validation fails the original value will be returned unmodified.

selected_verb = 'selected'
show_error = False
show_error__doc = "Should the field display it's own errors? Defaults to False because normally they're displayed by the container widget"
source_vars = frozenset([])
strip_name = False
strip_name__doc = "If this flag is True then the name of this widget will not be included in the fully-qualified names of the widgets in this subtree. This is useful to 'flatten-out' nested structures. This parameter can only be set during initialization."
style = None
style__doc = "Style properties for the field. It's recommended to use css classes and stylesheets instead of this parameter"
suppress_label = False
suppress_label__doc = 'Allows individual widgets to suppress the attached label in their container'
template = 'tw.forms.templates.select_field'
update_attrs(d, *args)

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)

update_params(d)
validate(value, state=None, use_request_local=True)

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.

validator

alias of DefaultValidator

value_at_request

Value being validated in current request.

walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.RecordFieldWidget(*args, **kw)

Bases: tw.core.base.Widget

adapt_value(value)

Adapt object value for rendering in this widget. Should return one of: * A list of objects for repeated widgets. * A dict for widgets with children, keyed by the children’s ids. * Any other object the widget understands.

add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

available_engines = []
children_deep
clone(*args, **kw)
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'toscawidgets'
get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
params = frozenset(['css_class', 'field_name', 'id', 'css_classes'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)

This method is called for all tw.api.Widget base classes to perform final setup after the widget is initialized but before it is locked.

prepare_dict(value, d, adapt=True)

Prepares the all kw arguments sent to display or render before passing the kw argument’s dict to update_params.

register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

source_vars = frozenset([])
template = 'genshi:sprox.widgets.templates.recordField'
update_params(d)

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'
walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.RecordViewWidget(*args, **kw)

Bases: tw.core.base.Widget

adapt_value(value)

Adapt object value for rendering in this widget. Should return one of: * A list of objects for repeated widgets. * A dict for widgets with children, keyed by the children’s ids. * Any other object the widget understands.

add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

available_engines = []
children_deep
clone(*args, **kw)
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'toscawidgets'
get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
params = frozenset(['css_class', 'entity', 'id', 'css_classes'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)

This method is called for all tw.api.Widget base classes to perform final setup after the widget is initialized but before it is locked.

prepare_dict(value, d, adapt=True)

Prepares the all kw arguments sent to display or render before passing the kw argument’s dict to update_params.

register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

source_vars = frozenset([])
template = 'genshi:sprox.widgets.templates.recordViewTable'
update_params(d)

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'
walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.TableDefWidget(*args, **kw)

Bases: tw.core.base.Widget

adapt_value(value)

Adapt object value for rendering in this widget. Should return one of: * A list of objects for repeated widgets. * A dict for widgets with children, keyed by the children’s ids. * Any other object the widget understands.

add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

available_engines = []
children_deep
clone(*args, **kw)
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'toscawidgets'
get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
params = frozenset(['css_class', 'identifier', 'id', 'css_classes'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)

This method is called for all tw.api.Widget base classes to perform final setup after the widget is initialized but before it is locked.

prepare_dict(value, d, adapt=True)

Prepares the all kw arguments sent to display or render before passing the kw argument’s dict to update_params.

register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

source_vars = frozenset([])
template = 'genshi:sprox.widgets.templates.tableDef'
update_params(d)

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'
walk(filter=None, recur_if_filtered=True)

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))
''
class sprox.widgets.TableLabelWidget(*args, **kw)

Bases: tw.core.base.Widget

adapt_value(value)

Adapt object value for rendering in this widget. Should return one of: * A list of objects for repeated widgets. * A dict for widgets with children, keyed by the children’s ids. * Any other object the widget understands.

add_call(call, location='bodybottom')

Adds a tw.api.js_function() call that will be made when the widget is rendered.

available_engines = []
children_deep
clone(*args, **kw)
css = []
css_class__doc = 'Main CSS class for this widget'
css_classes = []
css_classes__doc = 'A list with extra css classes for the widget.'
default = None
display(value=None, **kw)

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.

displays_on

Where the widget is being displayed on

engine_name = 'toscawidgets'
get_default()

Returns the default value for the widget. If the default is a funtion that it can be called without arguments it will be called on each render to retrieve a value

id

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'
id__doc = 'The id of this widget. This id is used to reference a widget from its parent ``children`` attribute and is usually the DOM id of outermost HTML tag of the widget.'
id_path_elem
ifilter_children(filter)

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']
is_root

True if the widget doesn’t have a parent

javascript = []
key

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'
params = frozenset(['css_class', 'controller', 'identifier', 'id', 'css_classes'])
parent = None
path

Iterates a walk from this widget to the root of the tree

post_init(*args, **kw)

This method is called for all tw.api.Widget base classes to perform final setup after the widget is initialized but before it is locked.

prepare_dict(value, d, adapt=True)

Prepares the all kw arguments sent to display or render before passing the kw argument’s dict to update_params.

register_resources()

Register the resources required by this Widget with tw.framework for inclusion in the page.

This method is called whenever a Widget is rendered

render(value=None, **kw)

Renders a widget as an unicode string.

retrieve_css(*args, **kw)
retrieve_javascript(*args, **kw)
retrieve_resources(*args, **kw)
root

The root of this widget tree

source_vars = frozenset([])
template = 'genshi:sprox.widgets.templates.tableLabel'
update_params(d)

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'
walk(filter=None, recur_if_filtered=True)

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))
''

Discuss

blog comments powered by Disqus

Table Of Contents

Previous topic

sprox.iprovider

Next topic

sprox.util

This Page