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

[Cheetahtemplate-discuss] Inserting additional placeholders

Expand Messages
  • Daniel Winter
    Hi, I want to use cheetah with cherryPy. To make things easier I created a helper that searches existing templates creates a instance of the cheetah Template
    Message 1 of 1 , Mar 24, 2013
    • 0 Attachment
      Hi,

      I want to use cheetah with cherryPy. To make things easier I created a helper that searches existing templates creates a instance of the cheetah Template class and returns it.
      Then I want to be able to add data to the searchList. But I couldn't find any method that allows me to add new data to the searchList.
      The only solution for me was to get a reference of the  searchList and append my data there. But I don't think that this is the right way to do it.

      This is basically what i do:


      #return the template
          def get_template(self, template):

              

              self.current_template = template + self.FILE_EXTENSION

              

              if (os.path.isfile(os.path.join(self.base_dir, self.current_template))):

                  

                  tmpl = Template(file = os.path.join(self.base_dir, self.current_template))

                  return tmpl



      ---------------

      # returns the template instance
              tmpl = cherrypy.engine.publish("lookup-template", template).pop()

              

      #get the searchList

              searchlist = tmpl.searchList()

              

      #add the data to the searchList

              searchlist.append(data)

      #set the response body
              cherrypy.response.body = str(tmpl)



    Your message has been successfully submitted and would be delivered to recipients shortly.