Understanding the schemas¶
ColanderAlchemy allows creating Colander schemas directly from SQLAlchemy model classes.
Additionally, c2cgeoform provides its own classes with extended features. A basic use case schema creation will look like:
from model import MyClass
schema = GeoFormSchemaNode(MyClass)
See the following API to understand what is going on behind the scene.
-
class
c2cgeoform.schema.
GeoFormSchemaNode
(*args, **kw)¶ An SQLAlchemySchemaNode with deferred request and dbsession properties. This will allow defining schemas that requires the request and dbsession at module-scope.
Example usage:
schema = GeoFormSchemaNode(MyModel) def create_form(request, dbsession): return Form( schema = schema.bind( request=request, dbsession=request.dbsession), ... )
-
add_unique_validator
(column, column_id)¶ Adds an unique validator on this schema instance.
- column
- SQLAlchemy ColumnProperty that should be unique.
- column_id
- SQLAlchemy MapperProperty that is used to recognize the entity, basically the primary key ColumnProperty.
-
-
class
c2cgeoform.schema.
GeoFormManyToManySchemaNode
(class_, includes=None, *args, **kw)¶ A GeoFormSchemaNode that properly handles many to many relationships.
- includes:
- Default to primary key name(s) only.
-
objectify
(dict_, context=None)¶ Method override that returns the existing ORM class instance instead of creating a new one.