changeset 49:e4828cb72ce2

working on json store
author casties
date Tue, 07 Sep 2010 11:26:59 +0200
parents 2ba80c8bb47f
children 29c822d15bc1
files RestDbJsonStore.py
diffstat 1 files changed, 20 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/RestDbJsonStore.py	Fri Sep 03 14:01:47 2010 +0200
+++ b/RestDbJsonStore.py	Tue Sep 07 11:26:59 2010 +0200
@@ -108,15 +108,14 @@
             # list of tags
             return self.showListOfTags(resultFormat=resultFormat,schema=path[1],table=path[2])
         elif len(path) == 4:
-            # list of tables
-            return self.showListOfTables(resultFormat=resultFormat,schema=path[1])
-        elif len(path) == 3:
-            # table
-            if REQUEST.get("method") == "POST" and REQUEST.get("create_table_file",None) is not None:
-                # POST to table to check
-                return self.checkTable(resultFormat=resultFormat,schema=path[1],table=path[2])
-            # else show table
-            return self.showTable(resultFormat=resultFormat,schema=path[1],table=path[2])
+            # list of types
+            return self.showListOfTypes(resultFormat=resultFormat,schema=path[1],table=path[2],tag=path[3])
+        elif len(path) == 5:
+            # list of types
+            return self.showListOfItems(resultFormat=resultFormat,schema=path[1],table=path[2],tag=path[3],type=path[4])
+        elif len(path) == 6:
+            # show item
+            return self.showItem(resultFormat=resultFormat,schema=path[1],table=path[2],tag=path[3],type=path[4],item=path[5])
         
         # don't know what to do
         return str(REQUEST)
@@ -125,12 +124,12 @@
         """
         Implement WebDAV/HTTP PUT/FTP put method for this object.
         """
-        logging.debug("RestDbInterface PUT")
+        path = REQUEST.get('restdb_path',[])
+        logging.debug("RestDbInterface PUT (path=%s)"%repr(path))
         #logging.debug("req=%s"%REQUEST)
         #self.dav__init(REQUEST, RESPONSE)
         #self.dav__simpleifhandler(REQUEST, RESPONSE)
         # ReST path was stored in request
-        path = REQUEST.get('restdb_path',[])
         if len(path) == 3:
             schema = path[1]
             tablename = path[2]
@@ -164,7 +163,17 @@
             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)
+        res = self.executeSQL(sql)
+        if len(res['rows']) > 0:
+            tags = [r[0] for r in rows]
+            return tags
         
+        return []
+    
 manage_addRestDbInterfaceForm=PageTemplateFile('zpt/addRestDbInterface',globals())
 
 def manage_addRestDbInterface(self, id, title='', label='', description='',