comparison RestDbJsonStore.py @ 50:29c822d15bc1

more JSON store
author casties
date Wed, 08 Sep 2010 12:03:15 +0200
parents e4828cb72ce2
children 17dcf148beb3
comparison
equal deleted inserted replaced
49:e4828cb72ce2 50:29c822d15bc1
160 160
161 else: 161 else:
162 # 400 Bad Request 162 # 400 Bad Request
163 RESPONSE.setStatus(400) 163 RESPONSE.setStatus(400)
164 return 164 return
165 165
166 def showListOfTags(self,resultFormat,schema,table): 166 def showListOfTags(self,resultFormat,schema,table):
167 """returns the list of existing tags""" 167 """returns the list of existing tags"""
168 logging.debug("showlistoftags schema=%s table=%s"%(schema,table)) 168 tags = self.getListOfTags(schema, table)
169 sql = 'select distinct gui_tags from "%s"."%s"'%(schema,table) 169 if resultFormat == 'JSON':
170 self.REQUEST.RESPONSE.setHeader("Content-Type", "application/json")
171 json.dump(tags, self.REQUEST.RESPONSE)
172 else:
173 json.dump(tags, self.REQUEST.RESPONSE)
174
175 def getListOfTags(self,schema,table):
176 """returns the list of existing tags"""
177 logging.debug("getlistoftags schema=%s table=%s"%(schema,table))
178 sql = 'select distinct json_tag from "%s"."%s"'%(schema,table)
170 res = self.executeSQL(sql) 179 res = self.executeSQL(sql)
171 if len(res['rows']) > 0: 180 if len(res['rows']) > 0:
172 tags = [r[0] for r in rows] 181 tags = [r[0] for r in rows]
173 return tags 182 return tags
174 183
175 return [] 184 return []
176 185
177 manage_addRestDbInterfaceForm=PageTemplateFile('zpt/addRestDbInterface',globals()) 186 manage_addRestDbJsonStoreForm=PageTemplateFile('zpt/addRestDbJsonStore',globals())
178 187
179 def manage_addRestDbInterface(self, id, title='', label='', description='', 188 def manage_addRestDbJsonStore(self, id, title='', label='', description='',
180 createPublic=0, 189 createPublic=0,
181 createUserF=0, 190 createUserF=0,
182 REQUEST=None): 191 REQUEST=None):
183 """Add a new object with id *id*.""" 192 """Add a new object with id *id*."""
184 193
185 ob=RestDbInterface(str(id),title) 194 ob=RestDbJsonStore(str(id),title)
186 self._setObject(id, ob) 195 self._setObject(id, ob)
187 196
188 #checkPermission=getSecurityManager().checkPermission 197 #checkPermission=getSecurityManager().checkPermission
189 REQUEST.RESPONSE.redirect('manage_main') 198 REQUEST.RESPONSE.redirect('manage_main')
190 199