- Timestamp:
- 04/27/10 11:46:53 (2 years ago)
- Files:
-
- 1 modified
-
framework/server/trunk/mapfish/lib/protocol.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
framework/server/trunk/mapfish/lib/protocol.py
r3368 r3462 188 188 before_create 189 189 a callback function called before a feature is inserted 190 in the database table, the function receives the request 191 and the feature about to be inserted. 190 in the database table, the function receives the request, 191 the feature read from the GeoJSON document sent in the 192 request, and the database object to be updated. The 193 latter is None if this is is an actual insertion. 192 194 193 195 before_update 194 196 a callback function called before a feature is updated 197 in the database table, the function receives the request, 198 the feature read from the GeoJSON document sent in the 199 request, and the database object to be updated. 200 201 before_delete 202 a callback function called before a feature is deleted 195 203 in the database table, the function receives the request 196 and the feature about to be updated.204 and the database object about to be deleted. 197 205 """ 198 206 … … 208 216 if kwargs.has_key('before_update'): 209 217 self.before_update = kwargs['before_update'] 218 self.before_delete = None 219 if kwargs.has_key('before_delete'): 220 self.before_delete = kwargs['before_delete'] 210 221 211 222 def _encode(self, objects, request, response): … … 343 354 create = False 344 355 obj = None 345 if self.before_create is not None:346 self.before_create(request, feature)347 356 if isinstance(feature.id, int): 348 357 obj = self.Session.query(self.mapped_class).get(feature.id) 358 if self.before_create is not None: 359 self.before_create(request, feature, obj) 349 360 if obj is None: 350 361 obj = self.mapped_class() … … 377 388 abort(400) 378 389 if self.before_update is not None: 379 self.before_update(request, feature )390 self.before_update(request, feature, obj) 380 391 obj.geometry = asShape(feature.geometry) 381 392 for key in feature.properties: … … 392 403 if obj is None: 393 404 abort(404) 405 if self.before_delete is not None: 406 self.before_delete(request, obj) 394 407 self.Session.delete(obj) 395 408 self.Session.commit()
