Mercurial > hg > ChinaGisRestApi
changeset 9:76ac7a721273
more rework of templates
author | casties |
---|---|
date | Wed, 21 Jul 2010 19:09:02 +0200 |
parents | a9a49f5765c9 |
children | f7f8ae43d436 |
files | RestDbInterface.py zpt/HTML_index.zpt zpt/HTML_schema.zpt zpt/HTML_schema_table.zpt |
diffstat | 4 files changed, 17 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/RestDbInterface.py Wed Jul 21 17:01:04 2010 +0200 +++ b/RestDbInterface.py Wed Jul 21 19:09:02 2010 +0200 @@ -155,9 +155,9 @@ def showTable(self,format='XML',schema='public',table=None): """returns PageTemplate with tables""" logging.debug("showtable") - pt = getattr(self.template, '%s_table'%format, None) + pt = getattr(self.template, '%s_schema_table'%format, None) if pt is None: - return "ERROR!! template %s_table not found"%format + return "ERROR!! template %s_schema_table not found"%format data = self.getTable(schema,table) return pt(data=data,tablename=table) @@ -172,9 +172,9 @@ def showListOfTables(self,format='XML',schema='public'): """returns PageTemplate with list of tables""" logging.debug("showlistoftables") - pt = getattr(self.template, '%s_list_tables'%format, None) + pt = getattr(self.template, '%s_schema'%format, None) if pt is None: - return "ERROR!! template %s_list_tables not found"%format + return "ERROR!! template %s_schema not found"%format data = self.getListOfTables(schema) return pt(data=data,schema=schema) @@ -194,9 +194,9 @@ def showListOfSchemas(self,format='XML'): """returns PageTemplate with list of schemas""" logging.debug("showlistofschemas") - pt = getattr(self.template, '%s_list_schemas'%format, None) + pt = getattr(self.template, '%s_index'%format, None) if pt is None: - return "ERROR!! template %s_list_schemas not found"%format + return "ERROR!! template %s_index not found"%format data = self.getListOfSchemas() return pt(data=data) @@ -205,7 +205,7 @@ """return list of schemas""" logging.debug("getlistofschemas") # TODO: really look up schemas - data={'fields':'schemas','data':'public'} + data={'fields': (('schemas',),), 'rows': [('public',),]} return data
--- a/zpt/HTML_index.zpt Wed Jul 21 17:01:04 2010 +0200 +++ b/zpt/HTML_index.zpt Wed Jul 21 19:09:02 2010 +0200 @@ -1,19 +1,19 @@ -<html tal:define="format python:request.get('format','table'); element_id python:request.get('element_id',None)"> +<html tal:define="layout python:request.get('layout','table'); element_id python:request.get('element_id',None)"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title tal:content="template/title">The title</title> </head> <body> <h2>List of schemas</h2> - <tal:block tal:condition="python:format=='select'"> + <tal:block tal:condition="python:layout=='select'"> <select tal:attributes="id element_id"> <option tal:repeat="sch options/data/data" tal:content="sch"/> </select> </tal:block> - <tal:block tal:condition="python:format=='table'"> + <tal:block tal:condition="python:layout=='table'"> <table tal:attributes="id element_id"> - <tr tal:repeat="sch options/data/data"> - <td><a tal:attributes="href sch" tal:content="sch"/></td> + <tr tal:repeat="row options/data/rows"> + <td><a tal:define="sch python:row[0]" tal:attributes="href sch" tal:content="sch"/></td> </tr> </table> </tal:block>
--- a/zpt/HTML_schema.zpt Wed Jul 21 17:01:04 2010 +0200 +++ b/zpt/HTML_schema.zpt Wed Jul 21 19:09:02 2010 +0200 @@ -1,16 +1,16 @@ -<html tal:define="format python:request.get('format','table'); element_id python:request.get('element_id',None)"> +<html tal:define="layout python:request.get('layout','table'); element_id python:request.get('element_id',None)"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title tal:content="template/title">The title</title> </head> <body> <h2>List of tables for schema <span tal:replace="options/schema"/></h2> - <tal:block tal:condition="python:format=='select'"> + <tal:block tal:condition="python:layout=='select'"> <select tal:attributes="id element_id"> <option tal:repeat="tbl options/data/rows" tal:content="python:tbl[0]"/> </select> </tal:block> - <tal:block tal:condition="python:format=='table'"> + <tal:block tal:condition="python:layout=='table'"> <table tal:attributes="id element_id"> <tr tal:repeat="row options/data/rows"> <td><a tal:define="tbl python:row[0]" tal:attributes="href tbl" tal:content="tbl"/></td>
--- a/zpt/HTML_schema_table.zpt Wed Jul 21 17:01:04 2010 +0200 +++ b/zpt/HTML_schema_table.zpt Wed Jul 21 19:09:02 2010 +0200 @@ -1,4 +1,4 @@ -<html tal:define="format python:request.get('format','table'); element_id python:request.get('element_id',None); +<html tal:define="layout python:request.get('layout','table'); element_id python:request.get('element_id',None); fields options/data/fields; rows options/data/rows;"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> @@ -6,7 +6,7 @@ </head> <body> <h2>table <span tal:replace="options/tablename"/></h2> - <tal:block tal:condition="python:format=='table'"> + <tal:block tal:condition="python:layout=='table'"> <table tal:attributes="id element_id"> <thead> <tr>