Table Of Contents

Previous topic

mapfish.sqlalchemygeom

This Page

mapfish.protocol

Protocol implementation

class mapfish.protocol.Protocol(Session, mapped_class, readonly=False, **kwargs)

Protocol class.

Session
the SQLAlchemy session.
mapped_class
the class mapped to a database table in the ORM.
readonly
True if this protocol is read-only, False otherwise. If True, the methods create(), update() and delete() will set 403 as the response status and return right away.
**kwargs
before_create
a callback function called before a feature is inserted in the database table, the function receives the request, the feature read from the GeoJSON document sent in the request, and the database object to be updated. The latter is None if this is is an actual insertion.
before_update
a callback function called before a feature is updated in the database table, the function receives the request, the feature read from the GeoJSON document sent in the request, and the database object to be updated.
before_delete
a callback function called before a feature is deleted in the database table, the function receives the request and the database object about to be deleted.
count(request, filter=None)

Return the number of records matching the given filter.

create(request, response, execute=True)

Read the GeoJSON feature collection from the request body and create new objects in the database.

delete(request, response, id)

Remove the targetted feature from the database

read(request, filter=None, id=None)

Build a query based on the filter or the idenfier, send the query to the database, and return a Feature or a FeatureCollection.

update(request, response, id)

Read the GeoJSON feature from the request body and update the corresponding object in the database.

Creating protocol filter

mapfish.protocol.create_default_filter(request, mapped_class, **kwargs)

Create MapFish default filter based on the request params. Additional named arguments are passed to the spatial filter.

mapfish.protocol.create_attr_filter(request, mapped_class)

Create an and_ SQLAlchemy filter (a ClauseList object) based on the request params (queryable, eq, ne, ...).

mapfish.protocol.create_geom_filter(request, mapped_class, **kwargs)

Create MapFish geometry filter based on the request params. Either a box or within or geometry filter, depending on the request params. Additional named arguments are passed to the spatial filter.