Re: placeholder "$request" - is it now reserved?
Brian Bird <[email protected]> Fri, 24 Aug 2012 14:59:16 +0000
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
--===============7551399715612389799== Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_6F7F60AEAD1E0D4B9958C3B7E7D2D4E31ED2ACSTExchange01Menai_" --_000_6F7F60AEAD1E0D4B9958C3B7E7D2D4E31ED2ACSTExchange01Menai_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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]] Sent: 06 August 2012 15:29 To: [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 --_000_6F7F60AEAD1E0D4B9958C3B7E7D2D4E31ED2ACSTExchange01Menai_ 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:11.0pt; font-family:"Calibri","sans-serif"; mso-fareast-language:EN-US;} 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"; mso-fareast-language:EN-US;} span.BalloonTextChar {mso-style-name:"Balloon Text Char"; mso-style-priority:99; mso-style-link:"Balloon Text"; font-family:"Tahoma","sans-serif";} span.EmailStyle19 {mso-style-type:personal; font-family:"Calibri","sans-serif"; color:windowtext;} span.EmailStyle20 {mso-style-type:personal-reply; font-family:"Calibri","sans-serif"; color:#1F497D;} .MsoChpDefault {mso-style-type:export-only; font-size:10.0pt;} @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"color:#1F497D">I’ve dug a littl= e further and it looks like the Servlet class (which is inherited by the Te= mplate class) contains 4 class variables:<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D">request, transaction, = application and session<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D"><o:p> </o:p></spa= n></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D">These variables appear= to mask any similarly named variables defined in the namespaces passed to = the Template constructor. This did not happen in Cheetah 2.0.<o:p></o:p></s= pan></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D"><o:p> </o:p></spa= n></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D">Is this a bug or a del= iberate change in design?<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D"><o:p> </o:p></spa= n></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D">I tried hacking the co= de to rename the class variables in Servlet and it makes the below code wor= k as expected for 3 of the variables (although this is hardly a good soluti= on). However, it still doesn’t work for the transaction variable because that also appears to be defined in th= e Template class.<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D"><o:p> </o:p></spa= n></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D">My assumption is that = the order of the objects searched in the VFFSL method is now different. I a= ssume this also means that other variable names may be unavailable for use = in a namespace too.<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D"><o:p> </o:p></spa= n></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D">Thanks for any help.<o= :p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D"><o:p> </o:p></spa= n></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D">Brian<o:p></o:p></span= ></p> <p class=3D"MsoNormal"><span style=3D"color:#1F497D"><o:p> </o:p></spa= n></p> <div> <div style=3D"border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm = 0cm 0cm"> <p class=3D"MsoNormal"><b><span lang=3D"EN-US" style=3D"font-size:10.0pt;fo= nt-family:"Tahoma","sans-serif";mso-fareast-language:EN= -GB">From:</span></b><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-fa= mily:"Tahoma","sans-serif";mso-fareast-language:EN-GB">= Brian Bird [mailto:[email protected]] <br> <b>Sent:</b> 06 August 2012 15:29<br> <b>To:</b> [email protected]<br> <b>Subject:</b> [Cheetahtemplate-discuss] placeholder "$request" = - is it now reserved?<o:p></o:p></span></p> </div> </div> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">I’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"><o:p> </o:p></p> <p class=3D"MsoNormal">from Cheetah.Template import Template<o:p></o:p></p> <p class=3D"MsoNormal">print Template(source=3D"Hello $x $request"= ;,namespaces=3D{"x":"X", "request":"REQU= EST"})<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">Cheetah 2.0:<o:p></o:p></p> <p class=3D"MsoNormal">Hello X REQUEST<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">Cheetah 2.4:<o:p></o:p></p> <p class=3D"MsoNormal">Hello X<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">It looks to me like the key “request” in= the namespace is being replaced with a blank value. (If I change the key t= o “request2” for example, it works as I expect.) Is “$req= uest” now reserved in the namespace? If so, are there any others?<o:p= ></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">Note, this upgrade happened because I’m moving= from Ubuntu 10.04 to Ubuntu 12.04. This means python has also been upgrade= d from 2.6 to 2.7. I can’t find anything in the documentation to sugg= est this is a deliberate change. I have seen some examples with the placeholder “$request” all to do with Webwar= e/Webkit. I don’t think I’m using either of these, but is there= a way to know for sure?<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">Thanks,<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">Brian<o:p></o:p></p> </div> </body> </html> --_000_6F7F60AEAD1E0D4B9958C3B7E7D2D4E31ED2ACSTExchange01Menai_-- --===============7551399715612389799== 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/ --===============7551399715612389799== 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 --===============7551399715612389799==--