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

4999Re: [Cheetahtemplate-discuss] placeholder "$request" - is it now reserved?

Expand Messages
  • Brian Bird
    Aug 28 1:39 AM
    • 0 Attachment

      As far as I can tell it’s not specifically doing anything for these variables. 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 and 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 all until after it has exhausted the namespaces. This appears to be the behaviour in Cheetah 2.0, so is there a deliberate reason this has changed?

       

      Thanks,

      Brian

       

      From: Buck Golemon [mailto:buck@...]
      Sent: 24 August 2012 16:47
      To: Brian Bird
      Cc: cheetahtemplate-discuss@...
      Subject: Re: [Cheetahtemplate-discuss] placeholder "$request" - is it now reserved?

       

      I doubt that the VFFSL function treats those variables specially. The current style (in cheetah) is to prefix cheetah internals with _CHEETAH_. It would seem quite valid to do so in this case as well.

      On Fri, Aug 24, 2012 at 7:59 AM, Brian Bird <Brian.Bird@...> wrote:

      I’ve dug a little further and it looks like the Servlet class (which is inherited 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 Cheetah 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 makes the below code work as expected for 3 of the variables (although this is hardly a good solution). However, it still doesn’t work for the transaction 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 be unavailable for use in a namespace too.

       

      Thanks for any help.

       

      Brian

       

      From: Brian Bird [mailto:Brian.Bird@...]
      Sent: 06 August 2012 15:29
      To: cheetahtemplate-discuss@...
      Subject: [Cheetahtemplate-discuss] placeholder "$request" - is it now reserved?

       

      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="Hello $x $request",namespaces={"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 with 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 find anything in the documentation to suggest this is a deliberate change. I have seen some examples with the placeholder “$request” all to do with Webware/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
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

       

    • Show all 4 messages in this topic