43
|
1 '''
|
|
2 Created on 2.9.2010
|
|
3
|
|
4 @author: casties, fknauft
|
|
5 '''
|
|
6
|
|
7 from OFS.Folder import Folder
|
|
8 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
|
|
9 from Products.ZSQLExtend import ZSQLExtend
|
|
10 import logging
|
|
11 import re
|
|
12 import json
|
|
13 import time
|
57
|
14 import urllib
|
43
|
15
|
|
16 from RestDbInterface import *
|
|
17
|
|
18
|
|
19 gisToSqlTypeMap = {
|
|
20 "text": "text",
|
|
21 "number": "numeric",
|
|
22 "id": "text",
|
|
23 "gis_id": "text",
|
|
24 "coord_lat": "numeric",
|
|
25 "coord_lon": "numeric"
|
|
26 }
|
|
27
|
55
|
28 def kmlEncode(s):
|
|
29 """returns string encoded for displaying in KML attribute"""
|
|
30 res = s.replace("'","__Apostroph__")
|
|
31 res = res.replace('"','__DoubleApostroph__')
|
|
32 res = res.replace(';','__$$__')
|
|
33 res = res.replace('&','&')
|
|
34 return res
|
|
35
|
|
36
|
43
|
37 class RestDbGisApi(RestDbInterface):
|
|
38 """Object for RESTful GIS database queries
|
|
39 path schema: /db/{schema}/{table}/
|
|
40 omitting table gives a list of schemas
|
|
41 omitting table and schema gives a list of schemas
|
|
42 """
|
|
43
|
|
44 meta_type="RESTgis"
|
|
45
|
|
46 # data templates
|
|
47 GIS_schema_table = PageTemplateFile('zpt/GIS_schema_table', globals())
|
55
|
48 KML_schema_table = PageTemplateFile('zpt/KML_schema_table', globals())
|
|
49
|
44
|
50 # and scripts
|
|
51 def KML_URL_schema_table(self,schema,table):
|
|
52 """KML_URL table function"""
|
|
53 self.REQUEST.RESPONSE.setHeader("Content-Type", "text/plain")
|
|
54 id = self.REQUEST.get('id',[])
|
|
55 doc = self.REQUEST.get('doc',None)
|
57
|
56 return self.getLiveKmlUrl(schema=schema,table=table)
|
44
|
57
|
43
|
58
|
|
59 def checkTableMetaPermission(self,action,schema,table,user=None):
|
|
60 """returns if the requested action on the table is allowed"""
|
|
61 logging.debug("checktablemetapermissions action=%s schema=%s table=%s user=%s"%(action,schema,table,user))
|
|
62 if user is None:
|
|
63 user = self.REQUEST.get('AUTHENTICATED_USER',None)
|
|
64 logging.debug("user=%s"%user)
|
|
65 # TODO: what now?
|
|
66 return True
|
|
67
|
|
68 def setTableMetaTypes(self,schema,table,fields):
|
|
69 """sets the GIS meta information for table"""
|
|
70 logging.debug("settablemetatypes schema=%s, table=%s, fields=%s"%(schema,table,fields))
|
|
71 gisIdField = None
|
|
72 latField = None
|
|
73 lonField = None
|
|
74 for f in fields:
|
|
75 t = f['type']
|
|
76 if t == 'gis_id':
|
|
77 gisIdField = f['name']
|
|
78 elif t == 'coord_lat':
|
|
79 latField = f['name']
|
|
80 elif t == 'coord_lon':
|
|
81 lonField = f['name']
|
|
82
|
|
83 res = self.executeSQL("select * from public.metadata where tablename=%s", (table,))
|
|
84 if len(res['rows']) > 0:
|
|
85 # meta record exists
|
|
86 if gisIdField is not None:
|
|
87 self.executeSQL('update public.metadata set "attribute with gis_id" = %s where tablename = %s', (gisIdField,table), hasResult=False)
|
|
88
|
|
89 else:
|
|
90 # new meta record
|
|
91 if gisIdField is not None:
|
|
92 self.executeSQL('insert into public.metadata ("tablename", "attribute with gis_id") values (%s, %s)', (table,gisIdField), hasResult=False)
|
|
93
|
|
94
|
|
95 def showTable(self,resultFormat='XML',schema='public',table=None,REQUEST=None,RESPONSE=None):
|
|
96 """returns PageTemplate with tables"""
|
|
97 logging.debug("showtable")
|
|
98 if REQUEST is None:
|
|
99 REQUEST = self.REQUEST
|
|
100
|
|
101 # should be cross-site accessible
|
|
102 if RESPONSE is None:
|
|
103 RESPONSE = self.REQUEST.RESPONSE
|
|
104
|
|
105 RESPONSE.setHeader('Access-Control-Allow-Origin', '*')
|
44
|
106
|
43
|
107 # everything else has its own template
|
|
108 pt = getattr(self.template, '%s_schema_table'%resultFormat, None)
|
|
109 if pt is None:
|
|
110 return "ERROR!! template %s_schema_table not found"%resultFormat
|
|
111
|
44
|
112 #data = self.getTable(schema,table)
|
|
113 # templates have to get their own data
|
|
114 return pt(schema=schema,table=table)
|
43
|
115
|
|
116
|
|
117 def createEmptyTable(self,schema,table,fields):
|
|
118 """create a table with the given fields
|
|
119 returns list of created fields"""
|
|
120 logging.debug("createEmptyTable")
|
|
121 sqlFields = []
|
|
122 for f in fields:
|
|
123 if isinstance(f,dict):
|
|
124 # {name: XX, type: YY}
|
|
125 name = sqlName(f['name'])
|
|
126 type = f['type']
|
|
127 sqltype = gisToSqlTypeMap[type]
|
|
128 else:
|
|
129 # name only
|
|
130 name = sqlName(f)
|
|
131 type = 'text'
|
|
132 sqltype = 'text'
|
|
133
|
|
134 sqlFields.append({'name':name, 'type':type, 'sqltype':sqltype})
|
|
135
|
|
136 if self.checkTableMetaPermission("create", schema, table):
|
|
137 self.executeSQL('drop table if exists "%s"."%s"'%(schema,table),hasResult=False)
|
|
138 fieldString = ", ".join(['"%s" %s'%(f['name'],f['sqltype']) for f in sqlFields])
|
|
139 sqlString = 'create table "%s"."%s" (%s)'%(schema,table,fieldString)
|
|
140 logging.debug("createemptytable: SQL=%s"%sqlString)
|
|
141 self.executeSQL(sqlString,hasResult=False)
|
|
142 self.setTableMetaTypes(schema,table,sqlFields)
|
|
143 return sqlFields
|
|
144 else:
|
|
145 logging.warning("create table not allowed!")
|
|
146 # throw exception?
|
|
147 return None
|
|
148
|
|
149
|
59
|
150 def getLiveKmlUrl(self,schema,table,useTimestamp=True,REQUEST=None):
|
57
|
151 if REQUEST is None:
|
|
152 REQUEST = self.REQUEST
|
55
|
153 logging.debug("getLiveKmlUrl")
|
|
154 baseUrl = self.absolute_url()
|
57
|
155 timestamp = time.time()
|
59
|
156 # filter parameters in URL and add to new URL
|
57
|
157 params = [p for p in REQUEST.form.items() if p[0] not in ('format','timestamp')]
|
|
158 params.append(('format','KML'))
|
59
|
159 if useTimestamp:
|
|
160 # add timestamp so URL changes every time
|
|
161 params.append(('timestamp',timestamp))
|
57
|
162 paramstr = urllib.urlencode(params)
|
|
163 return "%s/db/%s/%s?%s"%(baseUrl,schema,table,paramstr)
|
55
|
164
|
58
|
165 def getKmlData(self, schema, table, ids=None, sortBy=1, gisIdField=None, latField=None, lonField=None):
|
55
|
166 """returns data structure for KML template"""
|
59
|
167 logging.debug("getKMLdata gid=%s lat=%s lon=%s"%(gisIdField,latField,lonField))
|
55
|
168 # Mapping a set of points from table-based SQL-query:
|
|
169 qstr='SELECT * FROM "%s"."%s"'%(schema,table)
|
|
170 idList = None
|
|
171 if ids is not None:
|
|
172 qstr += ' WHERE '
|
|
173 if table=='mpdl':
|
|
174 qstr += 'mpdl_xmlsource_id IN ('
|
|
175 else:
|
|
176 qstr += 'CAST(id AS text) IN ('
|
|
177
|
|
178 idList = ids.split(",")
|
|
179 qstr += ','.join(['%s' for i in idList])
|
|
180 qstr += ')'
|
|
181
|
58
|
182 if sortBy:
|
|
183 # add sort clause
|
59
|
184 if sortBy == 1:
|
|
185 qstr += ' ORDER BY 1'
|
|
186 else:
|
|
187 # TODO: proper quoting for names
|
|
188 qstr += ' ORDER BY "%s"'%sortBy.replace('"','')
|
|
189
|
|
190 data = self.executeSQL(qstr,idList)
|
55
|
191
|
|
192 fieldMap = self.getFieldNameMap(data['fields'])
|
|
193
|
|
194 if (gisIdField is None) and (latField is None or lonField is None):
|
|
195 # no fields given - choose automagically
|
|
196 # gis id in metadata first
|
|
197 SQL='SELECT "attribute with gis_id" FROM public.metadata WHERE tablename = %s'
|
|
198 res = self.executeSQL(SQL, (table,))
|
|
199 if len(res['rows']) > 0:
|
|
200 gisIdField = res['rows'][0][0]
|
|
201 else:
|
|
202 logging.warning("no entry in metadata table for table %s"%table)
|
|
203 # try field names
|
|
204 if 'latitude' in fieldMap and 'longitude' in fieldMap:
|
|
205 latField = 'latitude'
|
|
206 lonField = 'longitude'
|
|
207 elif 'x_coord' in fieldMap and 'y_coord' in fieldMap:
|
|
208 latField = 'x_coord'
|
|
209 lonField = 'y_coord'
|
|
210 else:
|
|
211 logging.error("getKMLdata unable to find position fields")
|
|
212 return None
|
|
213
|
|
214 # convert field names to row indexes
|
|
215 gisIdIdx = fieldMap.get(gisIdField,None)
|
|
216 latIdx = fieldMap.get(latField,None)
|
|
217 lonIdx = fieldMap.get(lonField,None)
|
|
218 logging.debug("gisidfield=%s idx=%s"%(gisIdField,gisIdIdx))
|
|
219
|
|
220 # convert data
|
|
221 kmlData = []
|
|
222 for dataset in data['rows']:
|
|
223 if gisIdIdx is not None:
|
|
224 gisID = dataset[gisIdIdx]
|
58
|
225 coords=self.getPointForChGisId(gisID)
|
55
|
226 if coords!=None:
|
|
227 xCoord=coords[0]
|
|
228 yCoord=coords[1]
|
|
229
|
|
230 elif latIdx is not None:
|
|
231 xCoord = dataset[lonIdx]
|
|
232 yCoord = dataset[latIdx]
|
|
233
|
|
234 else:
|
|
235 logging.error("getKMLdata unable to find position")
|
|
236 return None
|
|
237
|
|
238 if float(xCoord) == 0.0:
|
|
239 continue
|
|
240
|
|
241 if float(yCoord) == 0.0:
|
|
242 continue
|
|
243
|
|
244 kmlPlace = {}
|
|
245
|
|
246 # description
|
|
247 desc = ''
|
|
248 i = -1
|
|
249 for value in dataset:
|
|
250 i += 1
|
|
251 name = data['fields'][i][0]
|
58
|
252 #logging.debug("value=%s"%value)
|
55
|
253 if value != None:
|
57
|
254 #if name.find('name')>-1:
|
|
255 # desc += "<name>%s</name>\n"%value
|
|
256 # continue
|
|
257 #elif name.find('place')>-1:
|
|
258 # desc += "<name>%s</name>\n"%value
|
|
259 # continue
|
55
|
260
|
|
261 val = "%s: %s"%(name, value)
|
|
262 if val.find('http')>-1:
|
|
263 val ='<a href="' + val + '" target="_blank">' + val + '</a>'
|
|
264
|
57
|
265 #desc += kmlEncode(val)
|
|
266 desc += val
|
55
|
267 desc += '<br/>\n'
|
|
268
|
57
|
269 #kmlPlace['description'] = "<![CDATA[%s]]>"%desc
|
|
270 kmlPlace['description'] = desc
|
55
|
271 kmlPlace['icon'] = '#marker_icon'
|
|
272 kmlPlace['coord_x'] = str(xCoord)
|
|
273 kmlPlace['coord_y'] = str(yCoord)
|
|
274 kmlPlace['coord_z'] = '0'
|
|
275 kmlData.append(kmlPlace)
|
|
276
|
|
277 #logging.debug("kmlData=%s"%(repr(kmlData)))
|
|
278 return kmlData
|
58
|
279
|
|
280 def getPointForChGisId(self, gis_id):
|
|
281 """returns coordinate pair for given gis_id"""
|
59
|
282 def getPoint(id):
|
|
283 sql="SELECT x_coord,y_coord FROM chgis.chgis_coords WHERE gis_id = %s"
|
|
284 res = self.executeSQL(sql, (gis_id,))
|
|
285 if len(res['rows']) > 0:
|
|
286 return res['rows'][0]
|
|
287 return None
|
|
288
|
58
|
289 if gis_id is None or gis_id == "":
|
|
290 return None
|
|
291
|
59
|
292 # try gis_id
|
|
293 coords = getPoint(gis_id)
|
|
294 if coords is None:
|
58
|
295 # try to clean gis_id...
|
|
296 gis_id = re.sub(r'[^0-9]','',gis_id)
|
|
297 # try again
|
59
|
298 coords = getPoint(gis_id)
|
|
299 if coords is None:
|
58
|
300 logging.error("CH-GIS ID %s not found!"%repr(gis_id))
|
|
301
|
|
302 # TODO: do we need the getCoordsFromREST_gisID stuff?
|
|
303
|
59
|
304 return coords
|
|
305
|
|
306
|
|
307 ## legacy methods...
|
|
308
|
|
309 def getKmlUrl(self,schema='chgis',table='mpdl',id=[],doc=None):
|
|
310 logging.debug("getKmlUrl")
|
|
311 data = self.getDataForGoogleMap(schema,table,id,doc)
|
|
312 kml=self.getKMLname(data=data,table=table)
|
|
313 baseUrl = self.absolute_url()
|
|
314 return "%s/daten/%s"%(baseUrl,kml)
|
|
315
|
|
316 def getDataForGoogleMap(self,schema='chgis',table='mpdl',id=None,doc=None):
|
|
317 logging.debug("getDataForGoogleMap")
|
|
318 qstr="SELECT * FROM "+schema+"."+table
|
|
319 try:
|
|
320 if id is not None:
|
|
321 qstr=qstr+" WHERE "
|
|
322 for id_item in id.split(","):
|
|
323 if table=='mpdl':
|
|
324 qstr=qstr+" mpdl_xmlsource_id = '"+id_item+ "' OR"
|
|
325 else:
|
|
326 qstr=qstr+" cast(id as text) LIKE '"+id_item+ "' OR"
|
|
327 qstr=str(qstr).rsplit(" ",1)[0] #to remove last " and "
|
|
328 data=self.ZSQLSimpleSearch(qstr)
|
|
329 return data
|
|
330 except:
|
|
331 return qstr
|
55
|
332
|
|
333
|
43
|
334 def getKMLname(self,data=[],table=""):
|
|
335 logging.debug("getKMLname")
|
|
336 #session=context.REQUEST.SESSION
|
|
337 kml4Marker="<kml xmlns=\'http://www.opengis.net/kml/2.2\'><Document><Style id=\'marker_icon\'><IconStyle><scale>15</scale><Icon><href>http://chinagis.mpiwg-berlin.mpg.de/chinagis/images/dot_red.png</href></Icon></IconStyle></Style>\n"
|
|
338 initializeStringForGoogleMaps=""
|
|
339 #doLine=container.getVar('doLine')
|
|
340 # Mapping a set of points from table-based SQL-query:
|
|
341 if data!=None:
|
|
342 try:
|
|
343 SQL='SELECT "attribute with gis_id" FROM public.metadata WHERE tablename = %s'
|
|
344 res = self.executeSQL(SQL, (table,))
|
|
345 gisIDattribute = res['rows'][0][0]
|
|
346 except:
|
|
347 return "table not registered within metadata"
|
|
348
|
|
349 for dataset in data:
|
|
350 try:
|
|
351 xCoord=getattr(dataset,'longitude')
|
|
352 yCoord=getattr(dataset,'latitude')
|
|
353 except:
|
|
354 try:
|
|
355 xCoord=getattr(dataset,'x_coord')
|
|
356 yCoord=getattr(dataset,'y_coord')
|
|
357 except:
|
|
358 #try:
|
|
359 gisID=getattr(dataset,gisIDattribute)
|
|
360 coords=self.getPoint4GISid(gisID)
|
|
361 if coords!=None:
|
|
362 xCoord=coords[0]
|
|
363 yCoord=coords[1]
|
|
364 # except:
|
|
365 # return "no coordinates found"
|
|
366
|
|
367 if float(xCoord)!=0:
|
|
368 if float(yCoord)!=0:
|
|
369 kml4Marker=kml4Marker+"<Placemark>"
|
|
370 kml4Marker=kml4Marker+"<description> <![CDATA[<b>"
|
|
371 for values in dataset:
|
55
|
372 #logging.debug("values=%s"%repr(values))
|
43
|
373 if values != (None, None):
|
|
374 if str(values).find('name')>-1:
|
|
375 kml4Marker=kml4Marker+"<name>"+str(values[1])+"</name>\n"
|
|
376 continue
|
|
377 elif str(values).find('place')>-1:
|
|
378 kml4Marker=kml4Marker+"<name>"+str(values[1])+"</name>\n"
|
|
379 continue
|
|
380
|
|
381 kml4Marker=kml4Marker+str(values)+": "
|
|
382 attribute_string=str(values).replace("'","__Apostroph__")
|
|
383 attribute_string=str(attribute_string).replace('"','__DoubleApostroph__')
|
|
384 attribute_string=str(attribute_string).replace(';','__$$__')
|
|
385 attribute_string=str(attribute_string).replace('&','&')
|
|
386 if str(attribute_string).find('http')>-1:
|
|
387 attribute_string='<A HREF=' + str(attribute_string) + ' target=_blank>' + str(attribute_string) + '</A>'
|
|
388 kml4Marker=kml4Marker+attribute_string+"</a><br>\n"
|
|
389
|
|
390 kml4Marker=kml4Marker+"]]></description>\n"
|
|
391 kml4Marker=kml4Marker+"<styleURL>#marker_icon</styleURL>\n"
|
|
392 kml4Marker=kml4Marker+"<Point>"
|
|
393
|
|
394 kml4Marker=kml4Marker+"<coordinates>"+str(xCoord)+","+str(yCoord)+",0</coordinates>\n"
|
|
395 kml4Marker=kml4Marker+"</Point>\n"
|
|
396 kml4Marker=kml4Marker+"</Placemark>\n"
|
|
397
|
|
398 kml4Marker=kml4Marker+"</Document>\n</kml>"
|
|
399 kmlFileName="marker"+str(time.time())+".kml"
|
|
400
|
|
401 #kml4Marker=str(kml4Marker).replace('&','$$')
|
|
402 #kml4Marker=str(kml4Marker).replace(';','__$$__')
|
|
403 #kml4Marker=str(kml4Marker).replace('#','__SHARP__')
|
|
404 isLoadReady='false'
|
|
405 while isLoadReady=='false':
|
|
406 isLoadReady=self.RESTwrite2File(self.daten,kmlFileName,kml4Marker)
|
|
407
|
|
408 return kmlFileName
|
|
409
|
44
|
410 # def getGoogleMapString(self,kml):
|
|
411 # logging.debug("getGoogleMapString")
|
|
412 # printed= '<body %s> '%kml +"""\n <div id="map_canvas" style="width: 98%; height: 95%"> </div> \n </body>" \n </html>"""
|
|
413 # return printed
|
43
|
414
|
|
415 def getPoint4GISid(self,gis_id):
|
|
416 j=0
|
|
417 coords=(0,0)
|
|
418 if gis_id != None:
|
|
419 while (True):
|
|
420 j=j+1
|
|
421 if (j>100): # FJK: just to prevent endless loops
|
|
422 break
|
|
423 if (gis_id.isdigit()): # FJK: regular exit from while-loop
|
|
424 break
|
|
425 else:
|
|
426 gis_id=gis_id.strip('abcdefghijklmnopqrstuvwxyz_') # FJK: to strip all letters
|
|
427 gis_id=gis_id.strip() # FJK: to strip all whitespaces
|
|
428 resultpoint = [0,0]
|
|
429 results = None
|
|
430 try:
|
|
431 if int(gis_id)>0:
|
|
432 SQL="SELECT x_coord,y_coord FROM chgis.chgis_coords WHERE gis_id LIKE cast("+ str(gis_id) +" as text);"
|
|
433 results=self.ZSQLSimpleSearch(SQL)
|
|
434 #print results
|
|
435 if results != None:
|
|
436 for result in results:
|
|
437 resultpoint=[getattr(result,str('x_coord')),getattr(result,str('y_coord'))]
|
|
438 if resultpoint !=[0,0]:
|
|
439 return resultpoint
|
|
440 else:
|
|
441 coords=self.getCoordsFromREST_gisID(joinid)
|
|
442 SQL="INSERT INTO chgis.chgis_coords (gis_id,x_coord,y_coord) VALUES (" +gis_id+ "," +coords[0][1]+ "," +coords[0][0]+ "); ANALYZE chgis.chgis_coords;"
|
|
443 returnstring=self.ZSQLSimpleSearch(SQL)
|
|
444 return coords[0]
|
|
445 except:
|
|
446 return "gis_id not to interpretable:"+str(gis_id)
|
|
447 else:
|
|
448 return coords[0]
|
|
449
|
|
450 def getCoordsFromREST_gisID(self,gis_id):
|
|
451 coordlist=[]
|
|
452 i=0
|
|
453 while (i<5 and coordlist==[]):
|
|
454
|
|
455 urlresponse=container.urlFunctions.zUrlopenParseString(container.urlFunctions.zUrlopenRead("http://chgis.hmdc.harvard.edu/xml/id/"+gis_id))
|
|
456 baseDocElement=container.urlFunctions.zUrlopenDocumentElement(urlresponse)
|
|
457 childnodes=container.urlFunctions.zUrlopenChildNodes(baseDocElement)
|
|
458 itemnodes=container.urlFunctions.zUrlopenGetElementsByTagName(baseDocElement,'item')
|
|
459
|
|
460 for i in range(0,container.urlFunctions.zUrlopenLength(itemnodes)):
|
|
461 itemnode=container.urlFunctions.zUrlopenGetItem(itemnodes,i)
|
|
462 itemspatialnodes=container.urlFunctions.zUrlopenGetElementsByTagName(itemnode,'spatial')
|
|
463 for j in range(0,container.urlFunctions.zUrlopenLength(itemspatialnodes)):
|
|
464 coord=[]
|
|
465 itemspatialnode= container.urlFunctions.zUrlopenGetItem(itemspatialnodes,j)
|
|
466 itemspatiallatnodes=container.urlFunctions.zUrlopenGetElementsByTagName(itemspatialnode,'degrees_latitude')
|
|
467 for k in range(0,container.urlFunctions.zUrlopenLength(itemspatiallatnodes)):
|
|
468 itemspatiallatnode= container.urlFunctions.zUrlopenGetItem(itemspatiallatnodes,k)
|
|
469 coord.append(container.urlFunctions.zUrlopenGetTextData(itemspatiallatnode))
|
|
470 itemspatiallngnodes=container.urlFunctions.zUrlopenGetElementsByTagName(itemspatialnode,'degrees_longitude')
|
|
471 for k in range(0,container.urlFunctions.zUrlopenLength(itemspatiallngnodes)):
|
|
472 itemspatiallngnode= container.urlFunctions.zUrlopenGetItem(itemspatiallngnodes,k)
|
|
473 coord.append(container.urlFunctions.zUrlopenGetTextData(itemspatiallngnode))
|
|
474 coordlist.append(coord)
|
|
475 gis_id= "_"+gis_id
|
|
476 return coordlist
|
|
477
|
|
478 # End for GoogleMaps creation
|
|
479
|
|
480 def RESTwrite2File(self,datadir, name,text):
|
|
481 logging.debug("RESTwrite2File datadir=%s name=%s"%(datadir,name))
|
|
482 try:
|
|
483 import cStringIO as StringIO
|
|
484 except:
|
|
485 import StringIO
|
|
486
|
|
487 # make filehandle from string
|
|
488 textfile = StringIO.StringIO(text)
|
|
489 fileid=name
|
|
490 if fileid in datadir.objectIds():
|
|
491 datadir.manage_delObjects(fileid)
|
|
492 fileInZope=datadir.manage_addFile(id=fileid,file=textfile)
|
|
493 return "Write successful"
|
|
494
|
|
495 def manage_editRestDbGisApi(self, title=None, connection_id=None,
|
|
496 REQUEST=None):
|
|
497 """Change the object"""
|
|
498 if title is not None:
|
|
499 self.title = title
|
|
500
|
|
501 if connection_id is not None:
|
|
502 self.connection_id = connection_id
|
|
503
|
|
504 #checkPermission=getSecurityManager().checkPermission
|
|
505 REQUEST.RESPONSE.redirect('manage_main')
|
|
506
|
|
507
|
|
508 manage_addRestDbGisApiForm=PageTemplateFile('zpt/addRestDbGisApi',globals())
|
|
509
|
|
510 def manage_addRestDbGisApi(self, id, title='', label='', description='',
|
|
511 createPublic=0,
|
|
512 createUserF=0,
|
|
513 REQUEST=None):
|
|
514 """Add a new object with id *id*."""
|
|
515
|
|
516 ob=RestDbGisApi(str(id),title)
|
|
517 self._setObject(id, ob)
|
|
518
|
|
519 #checkPermission=getSecurityManager().checkPermission
|
|
520 REQUEST.RESPONSE.redirect('manage_main')
|
|
521
|
|
522
|