Loading ...
Sorry, an error occurred while loading the content.

[Cheetahtemplate-discuss] Streaming output from Cheetah

Expand Messages
  • Aaron Held
    I am using the containment model in webware where I do something like: pageData = { atricles : dbLookupAndTextConversion(), news :anotherDBLookup() } t =
    Message 1 of 3 , Jul 18, 2003
    • 0 Attachment
      I am using the 'containment' model in webware where I do something like:

      pageData = {
      'atricles': dbLookupAndTextConversion(),
      'news':anotherDBLookup()
      }

      t = Template(file=Defautl.tmpl, searchList=pageData)
      self.write(t)

      So first the template gets filled, converted to a string, and then that
      string gets written.

      can I do:
      t.respond(trans=self.transaction())
      instead?

      Is that bad?


      --
      -Aaron
      http://www.MetroNY.com/
      "I don't know what's wrong with my television set. I was getting
      C-Span and the Home Shopping Network on the same station.
      I actually bought a congressman."
      - Bruce Baum





      -------------------------------------------------------
      This SF.net email is sponsored by: VM Ware
      With VMware you can run multiple operating systems on a single machine.
      WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
      same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Peter Lyons
      I d don t know if it s bad, but I do it as well. I use a split-inheritence approach where I have a class heirarchy of Webware servlets dealing with business
      Message 2 of 3 , Jul 18, 2003
      • 0 Attachment
        I'd don't know if it's bad, but I do it as well. I use a
        split-inheritence approach where I have a class heirarchy of Webware
        servlets dealing with business logic, and a totally separate class
        heirarchy of Cheetah Templates, only dealing with presentation. Here's
        the class that glues the two together.
        baseservlet.py
        -----------------------------------------------------------
        from WebKit.Page import Page

        class baseservlet(Page):
        """This class adds links Webware servlets to Cheetah templates.
        It includes the logic to generate its HTML content by finding a Cheetah
        template
        with the same name as this class plus the '_tmpl.tmpl' suffix.
        (This template has been previously complied into a python module 'named
        servletname_tmpl')
        It imports that template, registers itself as the template's servlet
        (containing the business logic the template may need), and then renders
        the template by calling its respond method and passing the resulting
        HTML string to the writeln() method."""

        def writeHTML(self):
        #print ">> baseservlet.writeHTML()"
        tmpl = self.template()
        tmpl.servlet = self
        self.writeln(tmpl.respond())

        def template(self):
        templateName = self.__class__.__name__ + '_tmpl'
        importLine = 'from %s import %s as template' % (templateName,
        templateName)
        exec(importLine)
        return template()

        def hasUser(self):
        return self.session().hasValue('user')
        ---------------------------------------------------------------------------


        Pete
        Aaron Held wrote:

        > I am using the 'containment' model in webware where I do something like:
        >
        > pageData = {
        > 'atricles': dbLookupAndTextConversion(),
        > 'news':anotherDBLookup()
        > }
        >
        > t = Template(file=Defautl.tmpl, searchList=pageData)
        > self.write(t)
        >
        > So first the template gets filled, converted to a string, and then
        > that string gets written.
        >
        > can I do:
        > t.respond(trans=self.transaction())
        > instead?
        >
        > Is that bad?
        >
        >



        -------------------------------------------------------
        This SF.net email is sponsored by: VM Ware
        With VMware you can run multiple operating systems on a single machine.
        WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
        same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      • Tavis Rudd
        ... Yes you can, and no it s not bad. It allows you to stream output and also to access the transaction object and the subjects within it from the template.
        Message 3 of 3 , Jul 18, 2003
        • 0 Attachment
          > Aaron Held wrote:
          > > I am using the 'containment' model in webware where I do something like:
          > >
          > > pageData = {
          > > 'atricles': dbLookupAndTextConversion(),
          > > 'news':anotherDBLookup()
          > > }
          > >
          > > t = Template(file=Defautl.tmpl, searchList=pageData)
          > > self.write(t)
          > >
          > > So first the template gets filled, converted to a string, and then
          > > that string gets written.
          > >
          > > can I do:
          > > t.respond(trans=self.transaction())
          > > instead?
          > >
          > > Is that bad?

          Yes you can, and no it's not bad. It allows you to stream output and also to
          access the transaction object and the subjects within it from the template.


          -------------------------------------------------------
          This SF.net email is sponsored by: VM Ware
          With VMware you can run multiple operating systems on a single machine.
          WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
          same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        Your message has been successfully submitted and would be delivered to recipients shortly.