This Page

Quick search

MapFish 1.2 is based on Pylons 0.9.7, and MapFish 2.0 is based on Pylons 1.0.
So to upgrade an application from MapFish 1.2 to MapFish 2.0 it is first needed
to upgrade that application from Pylons 0.9.7 to Pylons 1.0. For this refer to
the Pylons 1.0 Upgrading page,
and follow the provided indications.

MapFish 2.0 is based on GeoAlchemy. GeoAlchemy
provides extensions to SQLAlchemy for use with spatial databases. MapFish 2.0
no longer defines the Geometry type, the one defined by GeoAlchemy is to be
used instead.

With MapFish 1.2 the pastermf-layer command generated model files that
looked like this:

fromsqlalchemyimportColumn,Table,typesfromsqlalchemy.ormimportmapperfrommapfish.sqlalchemygeomimportGeometryfrommapfish.sqlalchemygeomimportGeometryTableMixInfromblonay.model.metaimportmetadata,engineusers_table=Table('users',metadata,Column('the_geom',Geometry(4326)),schema='my_schema',autoload=True,autoload_with=engine)classUser(GeometryTableMixIn):# for GeometryTableMixIn to do its job the __table__ property# must be set here__table__=users_tablemapper(User,users_table)

Concretely it means that you change your code not to rely on Spatial,
Comparison, Logical and FeatureId filters but on regular SQLAlchemy
ClauseElement objects. For example you would use and_ instead of
Logical, etc.

With the removal of the Filter abstraction the lib module is entirely
gone, and the protocol module is now located in mapfish. This means
your files that import protocol, typically controllers, should be changed.
Typical controllers must be changed from:

With MapFish 1.2 the pastermf-layer command generated controller files
that looked like this:

frompylonsimportrequest,response,session,tmpl_contextascfrompylons.controllers.utilimportabort,redirect_tofrommyproject.lib.baseimportBaseControllerfrommyproject.model.usersimportUserfrommyproject.model.metaimportSessionfrommyproject.lib.decoratorsimportgeojsonifyfrommapfish.protocolimportProtocol,create_default_filterclassUsersController(BaseController):readonly=False# if set to True, only GET is supporteddef__init__(self):self.protocol=Protocol(Session,User,self.readonly)defindex(self,format='json'):"""GET /: return all features."""returnself.protocol.index(request,response,format=format)defshow(self,id,format='json'):"""GET /id: Show a specific feature."""returnself.protocol.show(request,response,id)defcreate(self):"""POST /: Create a new feature."""returnself.protocol.create(request,response)defupdate(self,id):"""PUT /id: Update an existing feature."""returnself.protocol.update(request,response,id)defdelete(self,id):"""DELETE /id: Delete an existing feature."""returnself.protocol.delete(request,response,id)

With MapFish 2.0 the same user controller looks like this:

frompylonsimportrequest,response,session,tmpl_contextascfrompylons.controllers.utilimportabort,redirectfromtest.lib.baseimportBaseControllerfromtest.model.usersimportUserfromtest.model.metaimportSessionfrommapfish.protocolimportProtocol,create_default_filterfrommapfish.decoratorsimportgeojsonifyclassUsersController(BaseController):readonly=False# if set to True, only GET is supporteddef__init__(self):self.protocol=Protocol(Session,User,self.readonly)@geojsonifydefindex(self,format='json'):"""GET /: return all features."""ifformat!='json':abort(404)returnself.protocol.read(request)@geojsonifydefshow(self,id,format='json'):"""GET /id: Show a specific feature."""ifformat!='json':abort(404)returnself.protocol.read(request,response,id=id)@geojsonifydefcreate(self):"""POST /: Create a new feature."""returnself.protocol.create(request,response)@geojsonifydefupdate(self,id):"""PUT /id: Update an existing feature."""returnself.protocol.update(request,response,id)defdelete(self,id):"""DELETE /id: Delete an existing feature."""returnself.protocol.delete(request,response,id)

Several things to note here:

Protocols no longer expose index and show methods. They expose a
single method for reading features: read. So read is to be used
from both the index and show actions.

The index, show, create, and update methods no longer
return GeoJSON strings. Instead they return objects that can be
serialized into GeoJSON strings. This serialization is taken
care of by the geojsonify decorator.