comparison RestDbJsonStore.py @ 49:e4828cb72ce2

working on json store
author casties
date Tue, 07 Sep 2010 11:26:59 +0200
parents 2ba80c8bb47f
children 29c822d15bc1
comparison
equal deleted inserted replaced
48:2ba80c8bb47f 49:e4828cb72ce2
106 106
107 if len(path) == 3: 107 if len(path) == 3:
108 # list of tags 108 # list of tags
109 return self.showListOfTags(resultFormat=resultFormat,schema=path[1],table=path[2]) 109 return self.showListOfTags(resultFormat=resultFormat,schema=path[1],table=path[2])
110 elif len(path) == 4: 110 elif len(path) == 4:
111 # list of tables 111 # list of types
112 return self.showListOfTables(resultFormat=resultFormat,schema=path[1]) 112 return self.showListOfTypes(resultFormat=resultFormat,schema=path[1],table=path[2],tag=path[3])
113 elif len(path) == 3: 113 elif len(path) == 5:
114 # table 114 # list of types
115 if REQUEST.get("method") == "POST" and REQUEST.get("create_table_file",None) is not None: 115 return self.showListOfItems(resultFormat=resultFormat,schema=path[1],table=path[2],tag=path[3],type=path[4])
116 # POST to table to check 116 elif len(path) == 6:
117 return self.checkTable(resultFormat=resultFormat,schema=path[1],table=path[2]) 117 # show item
118 # else show table 118 return self.showItem(resultFormat=resultFormat,schema=path[1],table=path[2],tag=path[3],type=path[4],item=path[5])
119 return self.showTable(resultFormat=resultFormat,schema=path[1],table=path[2])
120 119
121 # don't know what to do 120 # don't know what to do
122 return str(REQUEST) 121 return str(REQUEST)
123 122
124 def PUT(self, REQUEST, RESPONSE): 123 def PUT(self, REQUEST, RESPONSE):
125 """ 124 """
126 Implement WebDAV/HTTP PUT/FTP put method for this object. 125 Implement WebDAV/HTTP PUT/FTP put method for this object.
127 """ 126 """
128 logging.debug("RestDbInterface PUT") 127 path = REQUEST.get('restdb_path',[])
128 logging.debug("RestDbInterface PUT (path=%s)"%repr(path))
129 #logging.debug("req=%s"%REQUEST) 129 #logging.debug("req=%s"%REQUEST)
130 #self.dav__init(REQUEST, RESPONSE) 130 #self.dav__init(REQUEST, RESPONSE)
131 #self.dav__simpleifhandler(REQUEST, RESPONSE) 131 #self.dav__simpleifhandler(REQUEST, RESPONSE)
132 # ReST path was stored in request 132 # ReST path was stored in request
133 path = REQUEST.get('restdb_path',[])
134 if len(path) == 3: 133 if len(path) == 3:
135 schema = path[1] 134 schema = path[1]
136 tablename = path[2] 135 tablename = path[2]
137 file = REQUEST.get("create_table_file",None) 136 file = REQUEST.get("create_table_file",None)
138 if file is None: 137 if file is None:
162 else: 161 else:
163 # 400 Bad Request 162 # 400 Bad Request
164 RESPONSE.setStatus(400) 163 RESPONSE.setStatus(400)
165 return 164 return
166 165
166 def showListOfTags(self,resultFormat,schema,table):
167 """returns the list of existing tags"""
168 logging.debug("showlistoftags schema=%s table=%s"%(schema,table))
169 sql = 'select distinct gui_tags from "%s"."%s"'%(schema,table)
170 res = self.executeSQL(sql)
171 if len(res['rows']) > 0:
172 tags = [r[0] for r in rows]
173 return tags
167 174
175 return []
176
168 manage_addRestDbInterfaceForm=PageTemplateFile('zpt/addRestDbInterface',globals()) 177 manage_addRestDbInterfaceForm=PageTemplateFile('zpt/addRestDbInterface',globals())
169 178
170 def manage_addRestDbInterface(self, id, title='', label='', description='', 179 def manage_addRestDbInterface(self, id, title='', label='', description='',
171 createPublic=0, 180 createPublic=0,
172 createUserF=0, 181 createUserF=0,