Mercurial > hg > ChinaGisRestApi
diff RestDbJsonStore.py @ 50:29c822d15bc1
more JSON store
author | casties |
---|---|
date | Wed, 08 Sep 2010 12:03:15 +0200 |
parents | e4828cb72ce2 |
children | 17dcf148beb3 |
line wrap: on
line diff
--- a/RestDbJsonStore.py Tue Sep 07 11:26:59 2010 +0200 +++ b/RestDbJsonStore.py Wed Sep 08 12:03:15 2010 +0200 @@ -162,11 +162,20 @@ # 400 Bad Request RESPONSE.setStatus(400) return - + def showListOfTags(self,resultFormat,schema,table): """returns the list of existing tags""" - logging.debug("showlistoftags schema=%s table=%s"%(schema,table)) - sql = 'select distinct gui_tags from "%s"."%s"'%(schema,table) + tags = self.getListOfTags(schema, table) + if resultFormat == 'JSON': + self.REQUEST.RESPONSE.setHeader("Content-Type", "application/json") + json.dump(tags, self.REQUEST.RESPONSE) + else: + json.dump(tags, self.REQUEST.RESPONSE) + + def getListOfTags(self,schema,table): + """returns the list of existing tags""" + logging.debug("getlistoftags schema=%s table=%s"%(schema,table)) + sql = 'select distinct json_tag from "%s"."%s"'%(schema,table) res = self.executeSQL(sql) if len(res['rows']) > 0: tags = [r[0] for r in rows] @@ -174,15 +183,15 @@ return [] -manage_addRestDbInterfaceForm=PageTemplateFile('zpt/addRestDbInterface',globals()) +manage_addRestDbJsonStoreForm=PageTemplateFile('zpt/addRestDbJsonStore',globals()) -def manage_addRestDbInterface(self, id, title='', label='', description='', +def manage_addRestDbJsonStore(self, id, title='', label='', description='', createPublic=0, createUserF=0, REQUEST=None): """Add a new object with id *id*.""" - ob=RestDbInterface(str(id),title) + ob=RestDbJsonStore(str(id),title) self._setObject(id, ob) #checkPermission=getSecurityManager().checkPermission