Exemple #1
0
 def delete(self):
     'Delete features'
     # Authenticate via personID or key
     personID = h.getPersonIDViaKey()
     if not personID:
         abort(401, 'Please log in or provide a valid key')
     # Load featureIDs
     featureIDs = request.params.get('featureIDs', '').splitlines()
     if not featureIDs:
         abort(400, 'Must specify at least one featureID in featureIDs')
     # Make sure that the user has write access to the given featureIDs
     try:
         model.getWritableFeatures(featureIDs, personID)
     except model.GeoRegistryError, error:
         abort(400, str(error))
 def delete(self):
     'Delete features'
     # Authenticate via personID or key
     personID = h.getPersonIDViaKey()
     if not personID:
         abort(401, 'Please log in or provide a valid key')
     # Load featureIDs
     featureIDs = request.params.get('featureIDs', '').splitlines()
     if not featureIDs:
         abort(400, 'Must specify at least one featureID in featureIDs')
     # Make sure that the user has write access to the given featureIDs
     try:
         model.getWritableFeatures(featureIDs, personID)
     except model.GeoRegistryError, error:
         abort(400, str(error))
Exemple #3
0
           'Must specify at least one feature in featureCollection')
 # Load tags
 try:
     tags = model.getTags(request.params.get('tags', ''),
                          addMissing=True)
 except model.GeoRegistryError, error:
     abort(400, str(error))
 # Load public
 public = request.params.get('public', 0)
 try:
     public = int(public)
 except ValueError:
     abort(400, 'Could not parse public=%s as an integer' % public)
 # Make sure that the user has write access to the given featureIDs
 try:
     featureByID = dict((x.id, x) for x in model.getWritableFeatures(
         [x.get('id') for x in featureDictionaries], personID))
 except model.GeoRegistryError, error:
     abort(400, str(error))
 # Prepare
 features = []
 # For each featureDictionary,
 for featureDictionary in featureDictionaries:
     # Expand
     featureID = featureDictionary.get('id')
     featureGeometry = featureDictionary.get('geometry')
     featureProperties = featureDictionary.get('properties', {})
     # Validate
     try:
         featureGeometryWKT = geoalchemy.utils.to_wkt(featureGeometry)
     except (KeyError, TypeError), error:
         abort(400, 'Could not parse geometry=%s' % featureGeometry)
 if not featureDictionaries:
     abort(400, 'Must specify at least one feature in featureCollection')
 # Load tags
 try:
     tags = model.getTags(request.params.get('tags', ''), addMissing=True)
 except model.GeoRegistryError, error:
     abort(400, str(error))
 # Load public
 public = request.params.get('public', 0)
 try:
     public = int(public)
 except ValueError:
     abort(400, 'Could not parse public=%s as an integer' % public)
 # Make sure that the user has write access to the given featureIDs
 try:
     featureByID = dict((x.id, x) for x in model.getWritableFeatures([x.get('id') for x in featureDictionaries], personID))
 except model.GeoRegistryError, error:
     abort(400, str(error))
 # Prepare
 features = []
 # For each featureDictionary,
 for featureDictionary in featureDictionaries:
     # Expand
     featureID = featureDictionary.get('id')
     featureGeometry = featureDictionary.get('geometry')
     featureProperties = featureDictionary.get('properties', {})
     # Validate
     try:
         featureGeometryWKT = geoalchemy.utils.to_wkt(featureGeometry)
     except (KeyError, TypeError), error:
         abort(400, 'Could not parse geometry=%s' % featureGeometry)