Inserting additional placeholders

Daniel Winter <[email protected]> Sun, 24 Mar 2013 21:55:31 +0100
Newsgroups gmane.comp.python.cheetah
Message-ID <[email protected]>
--===============5028706146599425461==
Content-type: multipart/alternative;
	boundary="Apple-Mail=_67948412-82EE-49EE-AE0C-2D742FF3F0EA"


--Apple-Mail=_67948412-82EE-49EE-AE0C-2D742FF3F0EA
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

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):
       =20
        self.current_template =3D template + self.FILE_EXTENSION
       =20
        if (os.path.isfile(os.path.join(self.base_dir, =
self.current_template))):
           =20
            tmpl =3D Template(file =3D os.path.join(self.base_dir, =
self.current_template))

            return tmpl



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

	# returns the template instance
        tmpl =3D cherrypy.engine.publish("lookup-template", =
template).pop()
       =20
	#get the searchList
        searchlist =3D tmpl.searchList()
       =20
	#add the data to the searchList
        searchlist.append(data)

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




--Apple-Mail=_67948412-82EE-49EE-AE0C-2D742FF3F0EA
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=us-ascii

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dus-ascii"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; =
">Hi,<div><br></div><div>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.</div><div>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.</div><div>The only solution for me was to get a reference of =
the &nbsp;searchList and append my data there. But I don't think that =
this is the right way to do it.</div><div><br></div><div>This is =
basically what i do:</div><div><br></div><div><br></div><div><span =
class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>#return =
the template</div><div><div style=3D"margin: 0px; font-size: 11px; =
font-family: Monaco; "><div style=3D"margin: 0px; ">&nbsp; =
&nbsp;&nbsp;<span style=3D"color: #0433ff">def</span> get_template(self, =
template):</div><p style=3D"margin: 0px; min-height: 15px; =
">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br =
class=3D"webkit-block-placeholder"></p><div style=3D"margin: 0px; =
">&nbsp; &nbsp; &nbsp; &nbsp; self.current_template =3D template + =
self.FILE_EXTENSION</div><p style=3D"margin: 0px; min-height: 15px; =
">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br =
class=3D"webkit-block-placeholder"></p><div style=3D"margin: 0px; =
">&nbsp; &nbsp; &nbsp; &nbsp; <span style=3D"color: #0433ff">if</span> =
(os.path.isfile(os.path.join(self.base_dir, =
self.current_template))):</div><p style=3D"margin: 0px; min-height: =
15px; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br =
class=3D"webkit-block-placeholder"></p><div style=3D"margin: 0px; =
">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpl =3D Template(file =3D =
os.path.join(self.base_dir, self.current_template))</div><div =
style=3D"margin: 0px; min-height: 15px; "><br></div><div style=3D"margin: =
0px; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=3D"color: =
#0433ff">return</span> tmpl</div><div style=3D"margin: 0px; =
"><br></div><div style=3D"margin: 0px; "><br></div><div style=3D"margin: =
0px; "><br></div><div style=3D"margin: 0px; ">---------------</div><div =
style=3D"margin: 0px; "><br></div><div style=3D"margin: 0px; "><span =
class=3D"Apple-tab-span" style=3D"white-space:pre">	</span># returns =
the template instance</div><div style=3D"margin: 0px; "><div =
style=3D"margin: 0px; ">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;tmpl =3D =
cherrypy.engine.publish(<span style=3D"color: =
#00b400">"lookup-template"</span>, template).pop()</div><p =
style=3D"margin: 0px; min-height: 15px; ">&nbsp;&nbsp; &nbsp; &nbsp; =
&nbsp;<br class=3D"webkit-block-placeholder"></p><p style=3D"margin: =
0px; min-height: 15px; "><span class=3D"Apple-tab-span" =
style=3D"white-space:pre">	</span>#get the searchList</p><div =
style=3D"margin: 0px; ">&nbsp; &nbsp; &nbsp; &nbsp; searchlist =3D =
tmpl.searchList()</div><p style=3D"margin: 0px; min-height: 15px; =
">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br =
class=3D"webkit-block-placeholder"></p><p style=3D"margin: 0px; =
min-height: 15px; "><span class=3D"Apple-tab-span" =
style=3D"white-space:pre">	</span>#add the data to the =
searchList</p><div style=3D"margin: 0px; ">&nbsp; &nbsp; &nbsp; &nbsp; =
searchlist.append(data)</div><div style=3D"margin: 0px; min-height: =
15px; "><br></div><div style=3D"margin: 0px; min-height: 15px; "><span =
class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>#set the =
response body</div><div style=3D"margin: 0px; ">&nbsp; &nbsp; &nbsp; =
&nbsp; cherrypy.response.body =3D str(tmpl)</div><div style=3D"margin: =
0px; "><br></div><div style=3D"margin: 0px; "><br></div><div =
style=3D"margin: 0px; "><br></div></div></div></div></body></html>=

--Apple-Mail=_67948412-82EE-49EE-AE0C-2D742FF3F0EA--


--===============5028706146599425461==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
--===============5028706146599425461==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Cheetahtemplate-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

--===============5028706146599425461==--