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

Re: [Cheetahtemplate-discuss] psyco and 0.9.18

Expand Messages
  • Bob Van Zant
    Technically you don t need the $ prefix on the i or the range in the #for line. #for i in range(5) $i #end for Works fine. -Bob ... This SF.Net email is
    Message 1 of 5 , Sep 29, 2005
    • 0 Attachment
      Technically you don't need the $ prefix on the 'i' or the range in the #for
      line.

      #for i in range(5)
      $i
      #end for

      Works fine.

      -Bob


      On 9/29/05 11:27 AM, "jose@..." <jose@...> wrote:

      > Was this a typo did you mean to type:
      > #for $i in $range(10)
      > ... $i
      > #end for
      >
      > rather than
      > #for $i in range(10)
      > ... $i
      > #end for
      >
      >
      > Jose
      >
      >
      >> -------- Original Message --------
      >> Subject: Re: [Cheetahtemplate-discuss] psyco and 0.9.18
      >> From: Shannon -jj Behrens <jjinux@...>
      >> Date: Thu, September 29, 2005 2:15 am
      >> To: William Dode <wilk-ml@...>
      >> Cc: cheetahtemplate-discuss@...
      >>
      >> If something works in Python, but not in Psyco, it's a bug in Psyco, no?
      >>
      >> -jj
      >>
      >> On 9/25/05, William Dode <wilk-ml@...> wrote:
      >>> Hi,
      >>>
      >>> The last version doesn't work with psyco
      >>>
      >>> Python 2.3.5 (#2, May 4 2005, 08:51:39)
      >>> [GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
      >>> Type "help", "copyright", "credits" or "license" for more information.
      >>>>>> import psyco
      >>>>>> psyco.full()
      >>>>>> from Cheetah.Template import Template
      >>>>>> print Template("""
      >>> ... #for $i in range(10)
      >>> ... $i
      >>> ... #end for
      >>> ... """)
      >>> Traceback (most recent call last):
      >>> File "<stdin>", line 1, in ?
      >>> File "<string>", line 28, in respond
      >>> NameMapper.NotFound: cannot find 'i'
      >>>>>>
      >>>
      >>> please ask if you want more details
      >>>
      >>> --
      >>> William Dodé - http://flibuste.net
      >>>
      >>>
      >>>
      >>> -------------------------------------------------------
      >>> SF.Net email is sponsored by:
      >>> Tame your development challenges with Apache's Geronimo App Server. Download
      >>> it for free - -and be entered to win a 42" plasma tv or your very own
      >>> Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
      >>> _______________________________________________
      >>> Cheetahtemplate-discuss mailing list
      >>> Cheetahtemplate-discuss@...
      >>> https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      >>>
      >>
      >>
      >> --
      >> I have decided to switch to Gmail, but messages to my Yahoo account will
      >> still get through.
      >>
      >>
      >> -------------------------------------------------------
      >> This SF.Net email is sponsored by:
      >> Power Architecture Resource Center: Free content, downloads, discussions,
      >> and more. http://solutions.newsforge.com/ibmarch.tmpl
      >> _______________________________________________
      >> Cheetahtemplate-discuss mailing list
      >> Cheetahtemplate-discuss@...
      >> https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      >
      >
      >
      > -------------------------------------------------------
      > This SF.Net email is sponsored by:
      > Power Architecture Resource Center: Free content, downloads, discussions,
      > and more. http://solutions.newsforge.com/ibmarch.tmpl
      > _______________________________________________
      > Cheetahtemplate-discuss mailing list
      > Cheetahtemplate-discuss@...
      > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss


      -------------------------------------------------------
      This SF.Net email is sponsored by:
      Power Architecture Resource Center: Free content, downloads, discussions,
      and more. http://solutions.newsforge.com/ibmarch.tmpl
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • mso@oz.net
      ... Something is blocking the Cheetah compiler from recognizing i as a local variable. The NameMapper should not have been called. My guess is psyco is
      Message 2 of 5 , Sep 29, 2005
      • 0 Attachment
        Shannon -jj Behrens wrote:
        > On 9/25/05, William Dode <wilk-ml@...> wrote:
        >> Hi,
        >>
        >> The last version doesn't work with psyco
        >>
        >> Python 2.3.5 (#2, May 4 2005, 08:51:39)
        >> [GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
        >> Type "help", "copyright", "credits" or "license" for more information.
        >> >>> import psyco
        >> >>> psyco.full()
        >> >>> from Cheetah.Template import Template
        >> >>> print Template("""
        >> ... #for $i in range(10)
        >> ... $i
        >> ... #end for
        >> ... """)
        >> Traceback (most recent call last):
        >> File "<stdin>", line 1, in ?
        >> File "<string>", line 28, in respond
        >> NameMapper.NotFound: cannot find 'i'
        >> >>>
        >>
        >> please ask if you want more details
        >>
        >> --
        >> William Dodé - http://flibuste.net


        Something is blocking the Cheetah compiler from recognizing 'i' as a local
        variable. The NameMapper should not have been called. My guess is psyco
        is miscompiling Cheetah. What if you import Template before activating
        psyco?

        The Cheetah compiler keeps track of local variables it has seen (via #set,
        #for, or passed by Cheetah as method arguments), global variables (via
        #import or otherwise imported), and builtins. $i and $range are compiled
        to bare variable names, so the usual Python lookup will be used. If the
        variable is not recognized, a NameMapper call is generated. That's
        apparently what happened here. '#set global' variables are handled a
        third way, but a NameMapper call is involved.

        In the #for directive, '$i' is translated to 'i' because it's on the left
        side. '$range' is translated to 'range' because it's a builtin. If you
        type 'i' and 'range' instead, Cheetah leaves it alone, assuming Python
        will know what to do with it. Since Python happens to use bare variable
        names, this works.

        --
        -- Mike Orr <mso@...>



        -------------------------------------------------------
        This SF.Net email is sponsored by:
        Power Architecture Resource Center: Free content, downloads, discussions,
        and more. http://solutions.newsforge.com/ibmarch.tmpl
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      Your message has been successfully submitted and would be delivered to recipients shortly.