Massimo
Thanks for the info. With a little extra that I finally found in the
examples, I now have a working solution that I include below in case
it helps anyone else.
Controller function
def static():
filename='applications/%s/static/html/%s.html'%
(request.application,request.vars.key)
try:
htmlfile=open(filename).read()
return dict(htmlfile=XML(htmlfile)) # works if html does not
contain {{ }}
except:
response.view="error.html"
return dict(message="Unable to open static html file
%s"%filename)
View - static.html
{{extend 'my_layout.html'}}
{{def sidepanel():}} <!-- not necessary for this particular problem --
>
{{include 'sidepanel.html'}}
{{return}}
{{def mainpanel():}} <!-- if not containing static file then amend as
required -->
<div id="content">
{{=htmlfile}}
</div>
{{return}}
Usage is:
a request like "
http://blah/my_application/my_controller/static?
key=puppy"
should return a page based on my_layout.html including a sidepanel
from views/sidepanel.html
and a main panel from my_application/static/html/puppy.html
If there is an error reading the target file then the response view is
"error.html" and it is passed a suitable message.
As I'm new to web2py and python I'd be interested in any feedback.
Bill