def incident_report():
 def prep(r):
  if (r.http == 'GET'):
   if (r.method in ('create', 'create.popup')):
    field = r.table.location_id
    lat = get_vars.get('lat', None)
    if (lat is not None):
     lon = get_vars.get('lon', None)
     if (lon is not None):
      form_vars = Storage(lat=float(lat), lon=float(lon))
      form = Storage(vars=form_vars)
      s3db.gis_location_onvalidation(form)
      id = s3db.gis_location.insert(**form_vars)
      field.default = id
    wkt = get_vars.get('wkt', None)
    if (wkt is not None):
     form_vars = Storage(wkt=wkt)
     form = Storage(vars=form_vars)
     s3db.gis_location_onvalidation(form)
     id = s3db.gis_location.insert(**form_vars)
     field.default = id
  return True
 s3.prep = prep
 return s3_rest_controller()

def incident_report ( ) : def prep ( r ) : if ( r . http == 'GET' ) : if ( r . method in ( 'create' , 'create.popup' ) ) : field = r . table . location_id lat = get_vars . get ( 'lat' , None ) if ( lat is not None ) : lon = get_vars . get ( 'lon' , None ) if ( lon is not None ) : form_vars = Storage ( lat = float ( lat ) , lon = float ( lon ) ) form = Storage ( vars = form_vars ) s3db . gis_location_onvalidation ( form ) id = s3db . gis_location . insert ( ** form_vars ) field . default = id wkt = get_vars . get ( 'wkt' , None ) if ( wkt is not None ) : form_vars = Storage ( wkt = wkt ) form = Storage ( vars = form_vars ) s3db . gis_location_onvalidation ( form ) id = s3db . gis_location . insert ( ** form_vars ) field . default = id return True s3 . prep = prep return s3_rest_controller ( )
restful crud controller .