annotate RestDbGisApi.py @ 55:2f4c427dec44

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