Also mein Code sieht folgendermaßen aus:
Code: Alles auswählen
import cx_Oracle
import json
import web
urls = (
"/grid", "grid"
)
app = web.application(urls, globals())
web.config.debug = True
connection = cx_Oracle.Connection("user/pssw@10.40.33.160:1521/sdetest", )
typeObj = connection.gettype("MDSYS.SDO_GEOMETRY")
class grid:
def GET(self):
web.header('Access-Control-Allow-Origin', '*')
web.header('Access-Control-Allow-Credentials', 'true')
web.header('Content-Type', 'application/json')
data = web.input()
id = int(data.ID)
a = [id]
cursor = connection.cursor()
cursor.arraysize = 10000
query = "SELECT a.id AS building_nr, c.geometry.sdo_ordinates AS geometry, d.Classname AS polygon_typ FROM building a, THEMATIC_SURFACE b, SURFACE_GEOMETRY c, OBJECTCLASS d WHERE a.id = b.BUILDING_ID AND b.LOD2_MULTI_SURFACE_ID = c.ROOT_ID AND c.GEOMETRY IS NOT NULL AND b.OBJECTCLASS_ID = d.ID AND a.grid_id_500 = %s;"
cursor.execute(query,a)
result = []
for id,geometry , classname in cursor:
result.append({"building_nr":id,"geometry":{"type":"polygon","coordinates":zip(*[iter(geometry.aslist())]*3),},"polygon_typ":classname,})
return json.dumps(result)
if __name__ == "__main__":
app.run()
Der Programmcode liegt auf einer Kopie des Dokumentenverzeichnisses wwwroot. Es ist nicht das originale.
Traceback
<type 'exceptions.UnicodeDecodeError'> at /grid
'ascii' codec can't decode byte 0xfc in position 36: ordinal not in range(128)
Python C:\Users\53_D_ML\Desktop\Masterthesis_15.06\wwwroot\REST\web\utils.py in safeunicode, line 351
Web GET
http://localhost:8080/grid
Traceback (innermost first)
C:\Users\53_D_ML\Desktop\Masterthesis_15.06\wwwroot\REST\web\utils.py in safeunicode
return unicode(obj) ...
▼ Local vars
Variable Value
encoding
'utf-8'
obj
DatabaseError(<cx_Oracle._Error object at 0x02C7BBE0>,)
t
<class 'cx_Oracle.DatabaseError'>
C:\Users\53_D_ML\Desktop\Masterthesis_15.06\wwwroot\REST\web\template.py in _escape
value = safeunicode(value) ...
▼ Local vars
Variable Value
escape
True
self
<web.template.Template instance at 0x02A68C88>
value
DatabaseError(<cx_Oracle._Error object at 0x02C7BBE0>,)
C:\Users\53_D_ML\Desktop\Masterthesis_15.06\wwwroot\REST\web\debugerror.pyc in __template__
▶ Local vars
C:\Users\53_D_ML\Desktop\Masterthesis_15.06\wwwroot\REST\web\debugerror.py in djangoerror
return t(exception_type, exception_value, frames) ...
▶ Local vars
C:\Users\53_D_ML\Desktop\Masterthesis_15.06\wwwroot\REST\web\debugerror.py in debugerror
return web._InternalError(djangoerror()) ...
C:\Users\53_D_ML\Desktop\Masterthesis_15.06\wwwroot\REST\web\application.py in internalerror
return debugerror.debugerror() ...
▶ Local vars
C:\Users\53_D_ML\Desktop\Masterthesis_15.06\wwwroot\REST\web\application.py in process
raise self.internalerror() ...
▶ Local vars
C:\Users\53_D_ML\Desktop\Masterthesis_15.06\wwwroot\REST\web\application.py in <lambda>
return p(lambda: process(processors)) ...
▶ Local vars
C:\Users\53_D_ML\Desktop\Masterthesis_15.06\wwwroot\REST\web\application.py in processor
return handler() ...
▶ Local vars
C:\Users\53_D_ML\Desktop\Masterthesis_15.06\wwwroot\REST\web\application.py in process
return p(lambda: process(processors)) ...
▶ Local vars