websauna.system.form.widgets module

Extra widgets.

Mostly for high level integration.

class websauna.system.form.widgets.FriendlyUUIDWidget(**kw)[source]

Bases: deform.widget.TextInputWidget

Display both UUID and base64 encoded string of a stored UUID value.

For websauna.form.field.UUID Colander type.

get_template_values(field, cstruct, kw)[source]
readonly_template = 'readonly/uuid'
class websauna.system.form.widgets.JSONWidget(cols=80, rows=10, style='font-family: monospace', prettyprint=True, **kwargs)[source]

Bases: deform.widget.TextAreaWidget

Nice JSON editor.

Prettyprints outgoing JSON for better readability.

Example usage:

import colander

from websauna.system.form.fields import JSONValue
from websauna.system.form.widgets import JSONWidget

class MySchema(colander.Schema):

    other_data = colander.SchemaNode(
        JSONValue(),
        widget=JSONWidget(),
        description="JSON bag of attributes of the object",
        missing=dict)
process_prettyprint(cstruct)[source]
readonly_template = 'readonly/json'
serialize(field, cstruct, **kw)[source]

The serialize method of a widget must serialize a cstruct value to an HTML rendering. A cstruct value is the value which results from a Colander schema serialization for the schema node associated with this widget. serialize should return the HTML rendering: the result of this method should always be a string containing HTML. The field argument is the field object to which this widget is attached. The **kw argument allows a caller to pass named arguments that might be used to influence individual widget renderings.