- Timestamp:
- 01/19/11 11:09:43 (16 months ago)
- Location:
- framework/server/trunk/mapfish
- Files:
-
- 4 modified
-
protocol.py (modified) (3 diffs)
-
sqlalchemygeom.py (modified) (1 diff)
-
tests/test_oracle.py (modified) (1 diff)
-
tests/test_protocol.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
framework/server/trunk/mapfish/protocol.py
r3715 r3724 307 307 self.Session.add(obj) 308 308 objects.append(obj) 309 # We call flush, create the feature collection, and then commit. Commit 310 # expires the session, so we create the feature collection before 311 # commit to avoid SELECT queries in toFeature. 312 if execute: 313 self.Session.flush() 314 collection = None 315 if len(objects) > 0: 316 collection = FeatureCollection([o.toFeature() for o in objects]) 309 317 if execute: 310 318 self.Session.commit() 311 319 response.status = 201 312 if len(objects) > 0: 313 features = [o.toFeature() for o in objects] 314 return FeatureCollection(features) 315 return 320 return collection 316 321 317 322 def update(self, request, response, id): … … 331 336 self.before_update(request, feature, obj) 332 337 self.__copy_attributes(feature, obj) 338 # We call flush, create the feature, and then commit. Commit expires 339 # the session, so we create the feature before commit to avoid SELECT 340 # queries in toFeature. 341 self.Session.flush() 342 feature = obj.toFeature() 333 343 self.Session.commit() 334 344 response.status = 201 335 return obj.toFeature()345 return feature 336 346 337 347 def delete(self, request, response, id): … … 352 362 """Updates the passed-in object with the values 353 363 from the GeoJSON feature.""" 354 # create a Shapely geometry from GeoJSON and persist the geometry using WKB 364 # create a Shapely geometry from GeoJSON and persist the geometry 365 # using WKB 355 366 shape = asShape(json_feature.geometry) 356 367 srid = self.mapped_class.geometry_column().type.srid 357 368 obj.geometry = WKBSpatialElement(buffer(shape.wkb), srid=srid) 358 # also store the Shapely geometry so that we can use it to return the geometry as GeoJSON 359 obj.geometry.shape = shape 369 # also store the Shapely geometry so that we can use it to return the 370 # geometry as GeoJSON and avoid a SELECT 371 obj._mf_shape = shape 360 372 for key in json_feature.properties: 361 373 obj[key] = json_feature.properties[key] -
framework/server/trunk/mapfish/sqlalchemygeom.py
r3715 r3724 209 209 attributes[k] = getattr(self, k) 210 210 211 if hasattr(self .geometry, 'shape') and self.geometry.shape is not None:211 if hasattr(self, '_mf_shape') and self._mf_shape is not None: 212 212 # we already have the geometry as Shapely geometry (when updating/inserting) 213 geometry = self. geometry.shape213 geometry = self._mf_shape 214 214 elif hasattr(self.geometry, 'geom_wkb') and self.geometry.geom_wkb is not None: 215 215 # create a Shapely geometry from the WKB geometry returned from the database -
framework/server/trunk/mapfish/tests/test_oracle.py
r3715 r3724 58 58 59 59 #engine = create_engine('oracle://gis:gis@localhost:1521/gis', echo=True) 60 engine = create_engine('oracle://system:system@172.16.103.13 4:1521/gis', echo=True)60 engine = create_engine('oracle://system:system@172.16.103.136:1521/gis', echo=True) 61 61 62 62 metadata = MetaData(engine) -
framework/server/trunk/mapfish/tests/test_protocol.py
r3659 r3724 330 330 for obj in Session.new: 331 331 assert obj["text"] == "foo" 332 assert obj. geometry.shape.x == 45333 assert obj. geometry.shape.y == 5332 assert obj._mf_shape.x == 45 333 assert obj._mf_shape.y == 5 334 334 Session.rollback()
