[Twisted-web] Can't subclass when docFactory is a loaders.stan instance.

Patrick B. Day uf069 at victoria.tc.ca
Thu Sep 9 13:06:37 MDT 2004


Is there anyway when constructing a page using stan to use render_*
methods which are defined in the subclass?

e.g.

class Template (rend.Page):
   docFactory=loaders.stan(T.html()[T.title()[T.span(render='title')]])

class Foo (Template):
   def render_title (self, ctx, data):
      return 'My title is Foo'


If I assign a string to render (in the T.span attribute) then the string
is just returned rather than a render_* method being called. If I assign a
render_* method (eg 'render_title') to render then the rendering is done
by calling the method in Template not in the subclass. For instance this
does not work:

class Template (rend.Page):
   def render_title (self, ctx, data):
      raise NotImplementedError

   docFactory = \
loaders.stan(T.html()[T.title()[T.span(render=render_title)]])

class Foo (Template):
   def render_title (self, ctx, data):
      return 'My title is Foo'


I don't have this issue if I use loaders.htmlfile() and store my stuff in
an html file. Thanks for your help.

-Pat.

============================

Patrick Day
uf069 at victoria.tc.ca



More information about the Twisted-web mailing list