On Tuesday 12 October 2004 16:19, Paul Moore wrote:
> This seems odd to me - I see my site in a more object oriented way -
> the standard format is a base class, and specific pages are
> subclasses, which in general only override the "content" method, but
> which could (for example) extend the "footer" method to add something
> to the footer. Something more like
>
> class Page(SitePage):
> def content [html] (request):
> #whatever
> def footer [html] (request):
> SitePage.footer(self, request)
> "The information on this page is confidential"
>
> You get the idea, I hope.
>
> I'm sure this is possible, but I can't quite get my head round how I
> structure things. Does anyone have any pointers to sample code that
> handles pages like this, or some hints on how to structure my
> interface like this (or, indeed warnings as to why this is a really
> bad idea!)
This really sound as Webware use SitePage :) ..
I get into the same trouble when i first come to Quixote. The simplest
way is to
__q_exports = []
def __q_index(req):
return Page(req)
and simply add the __call__ (or _q_index) in your SitePage class that
do the defaut behaviour.
class SitePage:
def __q_index(self,req):
self.head(req)
self.content(req) ...
self.footer(req)
The main difference between quixote or webware in this context, is
that : in Webware page rendering is bound to a transaction. so you
can access self.request or self.application without pain, this
is a bit more ticky.
Bye Bye