Subclassing a subclass of rend.Page
A quick question. I have a situation where I'm starting from a base html template, say 'template.html', which has some global elements which need rendering. So I do something like this: class Template (rend.Page): docFactory = rend.htmlfile('template.html') def render_global (self, context, data): """Fill in elements common to all pages.""" class GreetingsPage (Template): def render_contents (self, context, data): """Render contents area of page with greetings information.""" def render_sidebar (self, context, data): """Render sidebar area of page specific to greetings.""" When I try this approach though, nevow seems to make all it's rendering calls to Template and not GreetingsPage. What is the proper approach to doing what I'm trying to do? Thanks for your help. ============================ Patrick Day uf069@victoria.tc.ca
On Sep 1, 2004, at 1:50 PM, Patrick B. Day wrote:
A quick question. I have a situation where I'm starting from a base html template, say 'template.html', which has some global elements which need rendering. So I do something like this:
class Template (rend.Page): docFactory = rend.htmlfile('template.html') def render_global (self, context, data): """Fill in elements common to all pages."""
class GreetingsPage (Template): def render_contents (self, context, data): """Render contents area of page with greetings information."""
def render_sidebar (self, context, data): """Render sidebar area of page specific to greetings."""
When I try this approach though, nevow seems to make all it's rendering calls to Template and not GreetingsPage. What is the proper approach to doing what I'm trying to do?
This should work properly, as you expect it to. Are you sure the page you are rendering is actually an instance of GreetingsPage and not Template? dp
Arg! Sorry! It was actually a weird indenting thing where there wasn't an error but my program behavior changed in a way I've never come across before. (I'm working from userdb.py as my basis but I use tabs instead of spaces.) BTW I was coding my own web app stuff until I found Nevow. I'm impressed - finally someone realizes that sticking code in html documents is a not the greatest approach for web "applications". Thanks for your efforts and getting back to me so quickly. -Pat. On Wed, 1 Sep 2004, Donovan Preston wrote:
On Sep 1, 2004, at 1:50 PM, Patrick B. Day wrote:
A quick question. I have a situation where I'm starting from a base html template, say 'template.html', which has some global elements which need rendering. So I do something like this:
class Template (rend.Page): docFactory = rend.htmlfile('template.html') def render_global (self, context, data): """Fill in elements common to all pages."""
class GreetingsPage (Template): def render_contents (self, context, data): """Render contents area of page with greetings information."""
def render_sidebar (self, context, data): """Render sidebar area of page specific to greetings."""
When I try this approach though, nevow seems to make all it's rendering calls to Template and not GreetingsPage. What is the proper approach to doing what I'm trying to do?
This should work properly, as you expect it to. Are you sure the page you are rendering is actually an instance of GreetingsPage and not Template?
dp
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
participants (2)
-
Donovan Preston
-
Patrick B. Day