comparison RestDbInterface.py @ 25:cef1bfa821cb

fixed problem with not passing request
author casties
date Mon, 23 Aug 2010 10:57:59 +0200
parents f3811d9a36da
children 2b73f868d34f
comparison
equal deleted inserted replaced
24:f3811d9a36da 25:cef1bfa821cb
199 elif len(path) == 2: 199 elif len(path) == 2:
200 # list of tables 200 # list of tables
201 return self.showListOfTables(format=format,schema=path[1]) 201 return self.showListOfTables(format=format,schema=path[1])
202 elif len(path) == 3: 202 elif len(path) == 3:
203 # table 203 # table
204 if request.get("method") == "POST" and request.get("create_table_file",None) is not None: 204 if REQUEST.get("method") == "POST" and REQUEST.get("create_table_file",None) is not None:
205 # POST to table to check 205 # POST to table to check
206 return self.checkTable(format=format,schema=path[1],table=path[2]) 206 return self.checkTable(format=format,schema=path[1],table=path[2])
207 # else show table 207 # else show table
208 return self.showTable(format=format,schema=path[1],table=path[2]) 208 return self.showTable(format=format,schema=path[1],table=path[2])
209 209
248 248
249 def showTable(self,format='XML',schema='public',table=None,REQUEST=None,RESPONSE=None): 249 def showTable(self,format='XML',schema='public',table=None,REQUEST=None,RESPONSE=None):
250 """returns PageTemplate with tables""" 250 """returns PageTemplate with tables"""
251 logging.debug("showtable") 251 logging.debug("showtable")
252 # should be cross-site accessible 252 # should be cross-site accessible
253 if RESPONSE is None:
254 RESPONSE = self.REQUEST.RESPONSE
253 RESPONSE.setHeader('Access-Control-Allow-Origin', '*') 255 RESPONSE.setHeader('Access-Control-Allow-Origin', '*')
254 # GIS gets special treatment 256 # GIS gets special treatment
255 if format=="GIS": 257 if format=="GIS":
256 id = REQUEST.get('id',[]) 258 id = REQUEST.get('id',[])
257 doc = REQUEST.get('doc',None) 259 doc = REQUEST.get('doc',None)
273 275
274 def showListOfTables(self,format='XML',schema='public',REQUEST=None,RESPONSE=None): 276 def showListOfTables(self,format='XML',schema='public',REQUEST=None,RESPONSE=None):
275 """returns PageTemplate with list of tables""" 277 """returns PageTemplate with list of tables"""
276 logging.debug("showlistoftables") 278 logging.debug("showlistoftables")
277 # should be cross-site accessible 279 # should be cross-site accessible
280 if RESPONSE is None:
281 RESPONSE = self.REQUEST.RESPONSE
278 RESPONSE.setHeader('Access-Control-Allow-Origin', '*') 282 RESPONSE.setHeader('Access-Control-Allow-Origin', '*')
279 283
280 pt = getattr(self.template, '%s_schema'%format, None) 284 pt = getattr(self.template, '%s_schema'%format, None)
281 if pt is None: 285 if pt is None:
282 return "ERROR!! template %s_schema not found"%format 286 return "ERROR!! template %s_schema not found"%format
298 302
299 def showListOfSchemas(self,format='XML',REQUEST=None,RESPONSE=None): 303 def showListOfSchemas(self,format='XML',REQUEST=None,RESPONSE=None):
300 """returns PageTemplate with list of schemas""" 304 """returns PageTemplate with list of schemas"""
301 logging.debug("showlistofschemas") 305 logging.debug("showlistofschemas")
302 # should be cross-site accessible 306 # should be cross-site accessible
307 if RESPONSE is None:
308 RESPONSE = self.REQUEST.RESPONSE
303 RESPONSE.setHeader('Access-Control-Allow-Origin', '*') 309 RESPONSE.setHeader('Access-Control-Allow-Origin', '*')
304 310
305 pt = getattr(self.template, '%s_index'%format, None) 311 pt = getattr(self.template, '%s_index'%format, None)
306 if pt is None: 312 if pt is None:
307 return "ERROR!! template %s_index not found"%format 313 return "ERROR!! template %s_index not found"%format