changeset 50:29c822d15bc1

more JSON store
author casties
date Wed, 08 Sep 2010 12:03:15 +0200
parents e4828cb72ce2
children 17dcf148beb3
files RestDbJsonStore.py __init__.py zpt/addRestDbJsonStore.zpt
diffstat 3 files changed, 31 insertions(+), 32 deletions(-) [+]
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
--- a/__init__.py	Tue Sep 07 11:26:59 2010 +0200
+++ b/__init__.py	Wed Sep 08 12:03:15 2010 +0200
@@ -3,25 +3,6 @@
 import RestDbJsonStore
 import RestDbGisApi
 
-#class RESTinterface(DefaultPublishTraverse):
-#    """VLP spezifische Erweiterung der Collection"""
-#    
-#    meta_type="RESTinterface"
-#    
-#    implements(IPublishTraverse)
-#         
-#    def publishTraverse(self,request,name):
-#        """change the traversal if literature object"""
-#        
-#        actual_url=request['ACTUAL_URL']
-#        lastActual=actual_url.split("/")[-1]
-#   
-#           
-#        tr=DefaultPublishTraverse(self, request)
-#        ob= tr.publishTraverse(request, name)
-#       
-#        return ob
-
 def initialize(context):
 
     context.registerClass(
@@ -32,13 +13,13 @@
           )
         )
 
-#    context.registerClass(
-#         RestDbJsonStore.RestDbJsonStore,
-#        constructors = (
-#          RestDbJsonStore.manage_addRestDbJsonStoreForm,
-#          RestDbJsonStore.manage_addRestDbJsonStore
-#          )
-#        )
+    context.registerClass(
+         RestDbJsonStore.RestDbJsonStore,
+        constructors = (
+          RestDbJsonStore.manage_addRestDbJsonStoreForm,
+          RestDbJsonStore.manage_addRestDbJsonStore
+          )
+        )
 
     context.registerClass(
          RestDbGisApi.RestDbGisApi,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zpt/addRestDbJsonStore.zpt	Wed Sep 08 12:03:15 2010 +0200
@@ -0,0 +1,9 @@
+  <div tal:replace="structure here/manage_page_header">Header</div>
+  <h2>Add a RESTjson store</h2>
+  <form method="post" action="manage_addRestDbJsonStore">
+    <p class="form-label">ID</p>
+        <p class="form-element"><input size="80" name="id"/></p>
+    <p class="form-label">Title</p>
+        <p class="form-element"><input size="80" name="title"/></p>
+     <p><input type="submit" value="Add" /></p>
+  </form>