Table Of Contents

Previous topic

mapfish.sqlalchemygeom

Next topic

mapfish.lib.filters

This Page

mapfish.lib.protocol

Protocol implementation

class mapfish.lib.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 and the feature about to be inserted.
before_update
a callback function called before a feature is updated in the database table, the function receives the request and the feature about to be updated.
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
index(request, response, format='json', filter=None)
Build a query based on the filter and the request params, send the query to the database, and return a GeoJSON representation of the query results.
show(request, response, id, format='json')
Build a query based on the id argument, send the query to the database, and return a GeoJSON representation of the result.
update(request, response, id)
Read the GeoJSON feature from the request body and update the corresponding object in the database.

Creating protocol filter

mapfish.lib.protocol.create_default_filter(request, mapped_class)
Create MapFish default filter based on the request params.
mapfish.lib.protocol.create_attr_filter(request, mapped_class)
Create MapFish attribute filter based on the request params, either a comparison filter or a set of comparison filters within a logical and filter.
mapfish.lib.protocol.create_geom_filter(request, mapped_class)
Create MapFish geometry filter based on the request params. Either a box or within or geometry filter, depending on the request params.