# HG changeset patch
# User casties
# Date 1279724464 -7200
# Node ID a9a49f5765c936afc849f527b31d848e3ea9c40d
# Parent bd52d9445a4129ec8f6805dc22982980738b9f8c
reworking templates and schema
diff -r bd52d9445a41 -r a9a49f5765c9 RestDbInterface.py
--- a/RestDbInterface.py Tue Jul 20 15:09:32 2010 +0200
+++ b/RestDbInterface.py Wed Jul 21 17:01:04 2010 +0200
@@ -36,12 +36,12 @@
manage_editRestDbInterfaceForm=PageTemplateFile('zpt/editRestDbInterface',globals())
# data templates
- XML_list_schemas = PageTemplateFile('zpt/XML_list_schemas', globals())
- XML_list_tables = PageTemplateFile('zpt/XML_list_tables', globals())
- XML_table = PageTemplateFile('zpt/XML_table', globals())
- HTML_list_schemas = PageTemplateFile('zpt/HTML_list_schemas', globals())
- HTML_list_tables = PageTemplateFile('zpt/HTML_list_tables', globals())
- HTML_table = PageTemplateFile('zpt/HTML_table', globals())
+ XML_index = PageTemplateFile('zpt/XML_index', globals())
+ XML_schema = PageTemplateFile('zpt/XML_schema', globals())
+ XML_schema_table = PageTemplateFile('zpt/XML_schema_table', globals())
+ HTML_index = PageTemplateFile('zpt/HTML_index', globals())
+ HTML_schema = PageTemplateFile('zpt/HTML_schema', globals())
+ HTML_schema_table = PageTemplateFile('zpt/HTML_schema_table', globals())
@@ -108,7 +108,7 @@
# traverse
if len(path) == 0:
# first segment
- if name in ['XML','JSON','HTML']:
+ if name == 'db':
# virtual path -- continue traversing
path = [name]
request['restdb_path'] = path
@@ -125,17 +125,28 @@
def index_html(self,REQUEST,RESPONSE):
"""index method"""
+ # ReST path was stored in request
path = REQUEST.get('restdb_path',[])
- logging.debug("index_html path=%s"%path)
+ # type and format are real parameter
+ format = REQUEST.get('format','HTML').upper()
+ type = REQUEST.get('type',None)
+ logging.debug("index_html path=%s format=%s type=%s"%(path,format,type))
+
+ if type is not None:
+ # non-empty type -- look for template
+ pt = getattr(self.template, "%s_%s"%(format,type), None)
+ if pt is not None:
+ return pt(format=format,type=type,path=path)
+
if len(path) == 1:
# list of schemas
- return self.showListOfSchemas(format=path[0])
+ return self.showListOfSchemas(format=format)
elif len(path) == 2:
# list of tables
- return self.showListOfTables(format=path[0],schema=path[1])
+ return self.showListOfTables(format=format,schema=path[1])
elif len(path) == 3:
# table
- return self.showTable(format=path[0],schema=path[1],table=path[2])
+ return self.showTable(format=format,schema=path[1],table=path[2])
# don't know what to do
return str(REQUEST)
diff -r bd52d9445a41 -r a9a49f5765c9 zpt/HTML_index.zpt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zpt/HTML_index.zpt Wed Jul 21 17:01:04 2010 +0200
@@ -0,0 +1,21 @@
+
+
+
+ The title
+
+
+ List of schemas
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r bd52d9445a41 -r a9a49f5765c9 zpt/HTML_list_schemas.zpt
--- a/zpt/HTML_list_schemas.zpt Tue Jul 20 15:09:32 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-
-
-
- The title
-
-
- List of schemas
-
-
-
-
-
-
-
-
\ No newline at end of file
diff -r bd52d9445a41 -r a9a49f5765c9 zpt/HTML_list_tables.zpt
--- a/zpt/HTML_list_tables.zpt Tue Jul 20 15:09:32 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-
-
-
- The title
-
-
- List of tables for schema
-
-
-
-
-
-
-
-
\ No newline at end of file
diff -r bd52d9445a41 -r a9a49f5765c9 zpt/HTML_schema.zpt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zpt/HTML_schema.zpt Wed Jul 21 17:01:04 2010 +0200
@@ -0,0 +1,21 @@
+
+
+
+ The title
+
+
+ List of tables for schema
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r bd52d9445a41 -r a9a49f5765c9 zpt/HTML_schema_table.zpt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zpt/HTML_schema_table.zpt Wed Jul 21 17:01:04 2010 +0200
@@ -0,0 +1,24 @@
+
+
+
+ The title
+
+
+ table
+
+
+
+
+
\ No newline at end of file
diff -r bd52d9445a41 -r a9a49f5765c9 zpt/HTML_table.zpt
--- a/zpt/HTML_table.zpt Tue Jul 20 15:09:32 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-
-
-
- The title
-
-
- table
-
-
-
-
-
\ No newline at end of file
diff -r bd52d9445a41 -r a9a49f5765c9 zpt/XML_index.zpt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zpt/XML_index.zpt Wed Jul 21 17:01:04 2010 +0200
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff -r bd52d9445a41 -r a9a49f5765c9 zpt/XML_list_schemas.zpt
--- a/zpt/XML_list_schemas.zpt Tue Jul 20 15:09:32 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff -r bd52d9445a41 -r a9a49f5765c9 zpt/XML_list_tables.zpt
--- a/zpt/XML_list_tables.zpt Tue Jul 20 15:09:32 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-
-
-
-
\ No newline at end of file
diff -r bd52d9445a41 -r a9a49f5765c9 zpt/XML_schema.zpt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zpt/XML_schema.zpt Wed Jul 21 17:01:04 2010 +0200
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff -r bd52d9445a41 -r a9a49f5765c9 zpt/XML_schema_table.zpt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zpt/XML_schema_table.zpt Wed Jul 21 17:01:04 2010 +0200
@@ -0,0 +1,7 @@
+
+
diff -r bd52d9445a41 -r a9a49f5765c9 zpt/XML_table.zpt
--- a/zpt/XML_table.zpt Tue Jul 20 15:09:32 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-
-