websauna.system.form.sqlalchemy module¶
SQLAlchemy integration for Colander and Deform frameworks.
-
class
websauna.system.form.sqlalchemy.
ForeignKeyValue
(model=None)[source]¶ Bases:
websauna.system.form.sqlalchemy.ModelSchemaType
,colander.String
Hold a reference to one SQLAlchemy object for Colander schema serialization.
See Widgets for more information.
-
deserialize
(node, cstruct)[source]¶ Convert incoming form value - string id - back to a SQLAlchemy object.
-
preprocess_cstruct_value
(node, cstruct)[source]¶ Parse incoming form values to Python objects if needed.
-
-
class
websauna.system.form.sqlalchemy.
ModelSchemaType
(model=None)[source]¶ Bases:
object
Mixin class for using SQLAlchemy with Colander types.
Provide utilitiy functions to extract model and dbsession from the context.
-
label_column
= None¶ Name of the column which provides label or such for items in sequence. If not present item __str__ is used.
-
match_column
= None¶ Name of the column on the model we use to fetch objects using IN query
-
model
= None¶ Point this to the model this set is supposed to query
-
-
class
websauna.system.form.sqlalchemy.
ModelSet
(model=None)[source]¶ Bases:
websauna.system.form.sqlalchemy.ModelSchemaType
,colander.Set
Presents set of chosen SQLAlchemy models instances.
This automatically turns SQLAlchemy objects to (id, label) tuples, so that they can be referred in various widgets (select, checkbox).
See Widgets for more information.
-
preprocess_cstruct_values
(node, cstruct)[source]¶ Parse incoming form values to Python objects if needed.
-
-
class
websauna.system.form.sqlalchemy.
ModelSetResultList
[source]¶ Bases:
list
Mark that the result is through SQLAlchemy query.
-
class
websauna.system.form.sqlalchemy.
UUIDForeignKeyValue
(model, match_column=None)[source]¶ Bases:
websauna.system.form.sqlalchemy.ForeignKeyValue
Hold a reference to SQLAlchemy object through base64 encoded UUID value.
Useful for select widget, etc.
See Widgets for more information.
-
class
websauna.system.form.sqlalchemy.
UUIDModelSet
(model=None, match_column=None, label_column=None)[source]¶ Bases:
websauna.system.form.sqlalchemy.ModelSet
A set of SQLAlchemy objects queried by base64 encoded UUID value.
See Widgets for more information.
-
websauna.system.form.sqlalchemy.
convert_query_to_tuples
(query, first_column, second_column, default_choice=None)[source]¶ Convert SQLAlchemy query results to (id, name) tuples for select and checkbox widgets.
- Parameters
- Oaram default_choice
If given use this as “Select here” or when the value is None
- Return type