Re: placeholder "$request" - is it now reserved?

Brian Bird <[email protected]> Tue, 28 Aug 2012 08:39:08 +0000
Newsgroups gmane.comp.python.cheetah
Message-ID <[email protected]>
--===============1630583766288120668==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_6F7F60AEAD1E0D4B9958C3B7E7D2D4E31EDA82STExchange01Menai_"

--_000_6F7F60AEAD1E0D4B9958C3B7E7D2D4E31EDA82STExchange01Menai_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

As far as I can tell it's not specifically doing anything for these variabl=
es. I'm guessing Cheetah now searches the Template instance/class before it=
 searches the provided namespaces (whereas it used to search the namespaces=
 first). I've just tested with NonNumericInputError as a placeholder name a=
nd again, the value set in the Template class variables overrides the value=
 specified in the namespace.

It seems reasonable that the variables defined in the Template and Servlet =
ought to be prefixed with _CHEETAH_ as this would avoid the problem - but I=
 can't help but think it shouldn't be searching the Template instance at al=
l until after it has exhausted the namespaces. This appears to be the behav=
iour in Cheetah 2.0, so is there a deliberate reason this has changed?

Thanks,
Brian

From: Buck Golemon [mailto:[email protected]]
Sent: 24 August 2012 16:47
To: Brian Bird
Cc: [email protected]
Subject: Re: [Cheetahtemplate-discuss] placeholder "$request" - is it now r=
eserved?

I doubt that the VFFSL function treats those variables specially. The curre=
nt style (in cheetah) is to prefix cheetah internals with _CHEETAH_. It wou=
ld seem quite valid to do so in this case as well.
On Fri, Aug 24, 2012 at 7:59 AM, Brian Bird <[email protected]<m=
ailto:[email protected]>> wrote:
I've dug a little further and it looks like the Servlet class (which is inh=
erited by the Template class) contains 4 class variables:
request, transaction, application and session

These variables appear to mask any similarly named variables defined in the=
 namespaces passed to the Template constructor. This did not happen in Chee=
tah 2.0.

Is this a bug or a deliberate change in design?

I tried hacking the code to rename the class variables in Servlet and it ma=
kes the below code work as expected for 3 of the variables (although this i=
s hardly a good solution). However, it still doesn't work for the transacti=
on variable because that also appears to be defined in the Template class.

My assumption is that the order of the objects searched in the VFFSL method=
 is now different. I assume this also means that other variable names may b=
e unavailable for use in a namespace too.

Thanks for any help.

Brian

From: Brian Bird [mailto:[email protected]<mailto:Brian.Bird@sec=
uretrading.com>]
Sent: 06 August 2012 15:29
To: [email protected]<mailto:cheetahtemplate-di=
[email protected]>
Subject: [Cheetahtemplate-discuss] placeholder "$request" - is it now reser=
ved?

I've just upgraded from Cheetah 2.0 to Cheetah 2.4 and found the following =
code gives different output:

from Cheetah.Template import Template
print Template(source=3D"Hello $x $request",namespaces=3D{"x":"X", "request=
":"REQUEST"})

Cheetah 2.0:
Hello X REQUEST

Cheetah 2.4:
Hello X


It looks to me like the key "request" in the namespace is being replaced wi=
th a blank value. (If I change the key to "request2" for example, it works =
as I expect.) Is "$request" now reserved in the namespace? If so, are there=
 any others?

Note, this upgrade happened because I'm moving from Ubuntu 10.04 to Ubuntu =
12.04. This means python has also been upgraded from 2.6 to 2.7. I can't fi=
nd anything in the documentation to suggest this is a deliberate change. I =
have seen some examples with the placeholder "$request" all to do with Webw=
are/Webkit. I don't think I'm using either of these, but is there a way to =
know for sure?

Thanks,

Brian

---------------------------------------------------------------------------=
---
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Cheetahtemplate-discuss mailing list
[email protected]<mailto:Cheetahtemplate-discus=
[email protected]>
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss


--_000_6F7F60AEAD1E0D4B9958C3B7E7D2D4E31EDA82STExchange01Menai_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
	{mso-style-priority:99;
	mso-style-link:"Balloon Text Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:8.0pt;
	font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
	{mso-style-name:"Balloon Text Char";
	mso-style-priority:99;
	mso-style-link:"Balloon Text";
	font-family:"Tahoma","sans-serif";
	mso-fareast-language:EN-GB;}
span.EmailStyle19
	{mso-style-type:personal-reply;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri","sans-serif";
	mso-fareast-language:EN-US;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-GB" link=3D"blue" vlink=3D"purple">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D">As far as I can tell it&#=
8217;s not specifically doing anything for these variables. I&#8217;m guess=
ing Cheetah now searches the Template instance/class before it searches
 the provided namespaces (whereas it used to search the namespaces first). =
I&#8217;ve just tested with NonNumericInputError as a placeholder name and =
again, the value set in the Template class variables overrides the value sp=
ecified in the namespace.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D">It seems reasonable that =
the variables defined in the Template and Servlet ought to be prefixed with=
 _<i>CHEETAH</i>_ as this would avoid the problem &#8211; but
 I can&#8217;t help but think it shouldn&#8217;t be searching the Template =
instance at all until after it has exhausted the namespaces. This appears t=
o be the behaviour in Cheetah 2.0, so is there a deliberate reason this has=
 changed?<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D">Thanks,<o:p></o:p></span>=
</p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D">Brian<o:p></o:p></span></=
p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal"><b><span lang=3D"EN-US" style=3D"font-size:10.0pt;fo=
nt-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span =
lang=3D"EN-US" style=3D"font-size:10.0pt;font-family:&quot;Tahoma&quot;,&qu=
ot;sans-serif&quot;"> Buck Golemon [mailto:[email protected]]
<br>
<b>Sent:</b> 24 August 2012 16:47<br>
<b>To:</b> Brian Bird<br>
<b>Cc:</b> [email protected]<br>
<b>Subject:</b> Re: [Cheetahtemplate-discuss] placeholder &quot;$request&qu=
ot; - is it now reserved?<o:p></o:p></span></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt">I doubt that the VFFS=
L function treats those variables specially. The current style (in cheetah)=
 is to prefix cheetah internals with _CHEETAH_. It would seem quite valid t=
o do so in this case as well.<o:p></o:p></p>
<div>
<p class=3D"MsoNormal">On Fri, Aug 24, 2012 at 7:59 AM, Brian Bird &lt;<a h=
ref=3D"mailto:[email protected]" target=3D"_blank">Brian.Bird@se=
curetrading.com</a>&gt; wrote:<o:p></o:p></p>
<div>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">I&#8217;ve dug a little further and =
it looks like the Servlet class (which is inherited by the Template class) =
contains 4 class variables:</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">request, transaction, application an=
d session</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">These variables appear to mask any s=
imilarly named variables defined in the namespaces passed to the Template c=
onstructor. This did not happen in Cheetah
 2.0.</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">Is this a bug or a deliberate change=
 in design?</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">I tried hacking the code to rename t=
he class variables in Servlet and it makes the below code work as expected =
for 3 of the variables (although this
 is hardly a good solution). However, it still doesn&#8217;t work for the t=
ransaction variable because that also appears to be defined in the Template=
 class.</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">My assumption is that the order of t=
he objects searched in the VFFSL method is now different. I assume this als=
o means that other variable names may
 be unavailable for use in a namespace too.</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">Thanks for any help.</span><o:p></o:=
p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">Brian</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"color:#1F497D">&nbsp;</span><o:p></o:p></p>
<div>
<div style=3D"border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm =
0cm 0cm">
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><b><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-family:&quo=
t;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span lang=3D"EN-US"=
 style=3D"font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&=
quot;"> Brian
 Bird [mailto:<a href=3D"mailto:[email protected]" target=3D"_bl=
ank">[email protected]</a>]
<br>
<b>Sent:</b> 06 August 2012 15:29<br>
<b>To:</b> <a href=3D"mailto:[email protected]"=
 target=3D"_blank">
[email protected]</a><br>
<b>Subject:</b> [Cheetahtemplate-discuss] placeholder &quot;$request&quot; =
- is it now reserved?</span><o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">&nbsp;<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">I&#8217;ve just upgraded from Cheetah 2.0 to Cheetah 2.4 and found=
 the following code gives different output:<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">&nbsp;<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">from Cheetah.Template import Template<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">print Template(source=3D&quot;Hello $x $request&quot;,namespaces=
=3D{&quot;x&quot;:&quot;X&quot;, &quot;request&quot;:&quot;REQUEST&quot;})<=
o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">&nbsp;<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">Cheetah 2.0:<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">Hello X REQUEST<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">&nbsp;<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">Cheetah 2.4:<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">Hello X<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">&nbsp;<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">&nbsp;<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">It looks to me like the key &#8220;request&#8221; in the namespace=
 is being replaced with a blank value. (If I change the key to &#8220;reque=
st2&#8221; for example, it works as I expect.) Is &#8220;$request&#8221;
 now reserved in the namespace? If so, are there any others?<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">&nbsp;<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">Note, this upgrade happened because I&#8217;m moving from Ubuntu 1=
0.04 to Ubuntu 12.04. This means python has also been upgraded from 2.6 to =
2.7. I can&#8217;t find anything in the documentation
 to suggest this is a deliberate change. I have seen some examples with the=
 placeholder &#8220;$request&#8221; all to do with Webware/Webkit. I don&#8=
217;t think I&#8217;m using either of these, but is there a way to know for=
 sure?<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">&nbsp;<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">Thanks,<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">&nbsp;<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto">Brian<o:p></o:p></p>
</div>
</div>
</div>
</div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
---------------------------------------------------------------------------=
---<br>
Live Security Virtual Conference<br>
Exclusive live event will cover all the ways today's security and<br>
threat landscape has changed and how IT managers can respond. Discussions<b=
r>
will include endpoint security, mobile security and the latest in malware<b=
r>
threats. <a href=3D"http://www.accelacomm.com/jaw/sfrnl04242012/114/5012226=
3/" target=3D"_blank">
http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/</a><br>
_______________________________________________<br>
Cheetahtemplate-discuss mailing list<br>
<a href=3D"mailto:[email protected]">Cheetahtem=
[email protected]</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-dis=
cuss" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/cheeta=
htemplate-discuss</a><o:p></o:p></p>
</div>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

--_000_6F7F60AEAD1E0D4B9958C3B7E7D2D4E31EDA82STExchange01Menai_--


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

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
--===============1630583766288120668==
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

--===============1630583766288120668==--