def sync_one(self, row): """ Use to sync a single one of the instances that are bound to the `Grid`. """ # we want to allow the user to sync just rows w/o errors, so this is public if self.readonly: raise Exception('Cannot sync a read-only Grid') self._set_active(row) FieldSet.sync(self)
def sync_one(self, row): """ Use to sync a single one of the instances that are bound to the `Grid`. """ # we want to allow the user to sync just rows w/o errors, so this is public if self.readonly: raise Exception('Cannot sync a read-only Grid') self._set_active(row) FieldSet.sync(self)
def test_deserialize(self): params = {'Spot--the_geom': 'Point(0 1)', 'Spot--name': 'dummy'} session = FakeSession() spot_fieldset = FieldSet(Spot, data = params, session=session) spot_fieldset.the_geom.set(options=[('map_srid', 4326)]) spot_fieldset.validate() spot_fieldset.sync() ok_(isinstance(spot_fieldset.model.the_geom, WKTSpatialElement), 'Geometry was not assigned to model') eq_(str(spot_fieldset.model.the_geom), 'Point(0 1)', 'wkt is wrong') params = {'Spot--the_geom': ' ', 'Spot--name': ''} spot_fieldset = FieldSet(Spot, data = params, session=session) spot_fieldset.validate() spot_fieldset.sync() ok_(spot_fieldset.model.the_geom is None, 'Geometry is not set to None for empty strings')
def test_deserialize_reproject(self): params = {'Spot--the_geom': 'Point(0 1)', 'Spot--name': 'dummy'} session = FakeSession() spot_fieldset = FieldSet(Spot, data = params, session=session) spot_fieldset.the_geom.set(options=[('map_srid', 900913)]) spot_fieldset.validate() spot_fieldset.sync() ok_(isinstance(spot_fieldset.model.the_geom, WKTSpatialElement), 'Geometry was not assigned to model') eq_(spot_fieldset.model.the_geom.desc, 'geometry', 'The geometry was not reprojected for the insertion into the db') spot_fieldset.render() ok_(isinstance(session.scalar_args[0], functions.wkt), 'The geometry was not queried as WKT') ok_(isinstance(session.scalar_args[0].arguments[0], functions.transform), 'The geometry was not reprojected') params = {'Spot--the_geom': ' ', 'Spot--name': ''} spot_fieldset = FieldSet(Spot, data = params, session=session) spot_fieldset.validate() spot_fieldset.sync() ok_(spot_fieldset.model.the_geom is None, 'Geometry is not set to None for empty strings')