websauna.system.form.colander module

Highly modified colanderalchemy core.


This is a temporary solution and will be replaced with something cleaner after working with the upstream author.

class websauna.system.form.colander.PropertyAwareSQLAlchemySchemaNode(class_, dbsession, includes=None, excludes=None, overrides=None, unknown='ignore', nested=False, type_overrides=None, relationship_overrides=None, automatic_relationships=False, **kw)[source]

Bases: colanderalchemy.schema.SQLAlchemySchemaNode

ColanderAlchemy mapper with some extensions.

Allow automatically map of JSON’ed properties besides SQL Alchemy columns.

Allow type_overrides.


The original function is the most well written horrifying piece of Python code I have seen. The author has good intentions and has build a fantastic extension mechanism which is mostly useless for us. Furthermore the original code functions are so long that they are very fragile to change via subclassing. Overriding a colander type for SQLAlchemy column type was impossible and we patch our own extension mechanism in here.

TODO: Resolve the issue with the colanderalchemy author politically correct way. What we are doing now is just a temporary 0.1 solution.

add_nodes(includes, excludes, overrides, nested)[source]

Clone the schema node and return the clone. All subnodes are also cloned recursively. Attributes present in node dictionaries are preserved.


Extended to handle JSON properties.

get_schema_from_column(prop, overrides)[source]

Extended to handle JSON/JSONB.

get_schema_from_relationship(prop, overrides)[source]

Extended for property support.

objectify(dict_, context=None)[source]

Extended to handle JSON properties.

class websauna.system.form.colander.TypeOverridesHandling(*enums, **kw)[source]

Bases: sqlalchemy.sql.sqltypes.Enum

drop = 1

Return value from type_overrides signaling that this column should not appear on the form

unknown = 2

Type overrides don’t want to deal with this column let it proceed as is