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

[Cheetahtemplate-discuss] 2 small oddities

Expand Messages
  • Daniel Thaler
    Hi, I ve just begun trying out cheetah (1.0) and I ran into 2 small oddities: 1) I saved the FrogBase.tmpl and Frog1.tmpl locally for experimentation.
    Message 1 of 5 , Dec 16, 2005
      Hi,

      I've just begun trying out cheetah (1.0) and I ran into 2 small oddities:

      1) I saved the "FrogBase.tmpl" and "Frog1.tmpl" locally for experimentation.
      cheetah compile worked as expected and produced the corresponding .py files.
      I expected that "cheetah fill Frog1.tmpl" would then give me html output.
      What i _got_ was an error:

      $ cheetah fill Frog1.tmpl
      [...]
      File "/usr/lib/python2.4/site-packages/Cheetah/Template.py", line 446, in
      _importAsDummyModule
      exec co in mod.__dict__
      File "2005121620281428266.py", line 1, in ?
      ImportError: No module named FrogBase

      Then I tried
      $ cheetah fill Frog1.py
      [...]
      File "/usr/lib/python2.4/site-packages/Cheetah/Parser.py", line 1817, in
      assertEmptyIndentStack
      msg="Parsing claims it's done, items remaining on stack: %s" %(
      Cheetah.Parser.ParseError:

      Parsing claims it's done, items remaining on stack: def, def, def at line 203,
      column 1 in file /home/daniel/dev/cheetah-test/Frog1.py

      Line|Line contents
      ----|-------------------------------------------------------------
      200 |## if run from command line:
      201 |if __name__ == '__main__':
      202 | Frog1().runAsMainProgram()
      203 |
      ^

      No luck there either.
      In the end it turned out not to be a problem because I could get output by running
      $ python Frog1.py

      I don't know wether I just didn't understand the documentation or if it's a bug,
      but maybe you'd add a few words to the docs about how cheetah fill is meant to
      be used? And what use does cheetah fill have when one can simply run the .py?


      2) I then began testing with a fragment of the webpage I hope to use cheetah
      for. To keep things tidy I decided to have input and output in different
      directories.
      So according to the docs I compiled my file Frame.templ like this:

      $ cheetah compile --odir py/ --idir tmpl/ Frame.tmpl
      Compiling tmpl/Frame.tmpl -> py/tmpl/Frame.py
      Not what I expected.

      However:
      $ cheetah compile --odir py/ --idir tmpl Frame.tmpl
      Compiling tmpl/Frame.tmpl -> py/Frame.py
      IOW --idir is sensitive to trailing slashes.
      I think that's a bug.


      Bye,
      Daniel


      -------------------------------------------------------
      This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
      for problems? Stop! Download the new AJAX search engine that makes
      searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
      http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Tavis Rudd
      Hi Daniel, the import issue occurs because Python can t import FrogBase.tmpl. It can only import FrogBase.py, unless you have Cheetah s ImportHooks installed.
      Message 2 of 5 , Dec 16, 2005
        Hi Daniel,
        the import issue occurs because Python can't import FrogBase.tmpl. It can
        only import FrogBase.py, unless you have Cheetah's ImportHooks installed. To
        work around this limitation when using the 'fill' command you should run
        'cheetah compile' first. It will create the required FrogBase.py.

        The other error you saw with 'cheetah fill Frog1.py' is because Cheetah is
        expecting Cheetah source files, not Python ones.

        The final issue with the trailing slashes does look like a bug. I'll look
        into it next week.
        Cheers,
        Tavis

        On Friday 16 December 2005 11:47 am, Daniel Thaler wrote:
        > Hi,
        >
        > I've just begun trying out cheetah (1.0) and I ran into 2 small oddities:
        >
        > 1) I saved the "FrogBase.tmpl" and "Frog1.tmpl" locally for
        > experimentation. cheetah compile worked as expected and produced the
        > corresponding .py files. I expected that "cheetah fill Frog1.tmpl" would
        > then give me html output. What i _got_ was an error:
        >
        > $ cheetah fill Frog1.tmpl
        > [...]
        > File "/usr/lib/python2.4/site-packages/Cheetah/Template.py", line 446,
        > in _importAsDummyModule
        > exec co in mod.__dict__
        > File "2005121620281428266.py", line 1, in ?
        > ImportError: No module named FrogBase
        >
        > Then I tried
        > $ cheetah fill Frog1.py
        > [...]
        > File "/usr/lib/python2.4/site-packages/Cheetah/Parser.py", line 1817, in
        > assertEmptyIndentStack
        > msg="Parsing claims it's done, items remaining on stack: %s" %(
        > Cheetah.Parser.ParseError:
        >
        > Parsing claims it's done, items remaining on stack: def, def, def at line
        > 203, column 1 in file /home/daniel/dev/cheetah-test/Frog1.py
        >
        > Line|Line contents
        > ----|-------------------------------------------------------------
        > 200 |## if run from command line:
        > 201 |if __name__ == '__main__':
        > 202 | Frog1().runAsMainProgram()
        > 203 |
        > ^
        >
        > No luck there either.
        > In the end it turned out not to be a problem because I could get output by
        > running $ python Frog1.py
        >
        > I don't know wether I just didn't understand the documentation or if it's a
        > bug, but maybe you'd add a few words to the docs about how cheetah fill is
        > meant to be used? And what use does cheetah fill have when one can simply
        > run the .py?
        >
        >
        > 2) I then began testing with a fragment of the webpage I hope to use
        > cheetah for. To keep things tidy I decided to have input and output in
        > different directories.
        > So according to the docs I compiled my file Frame.templ like this:
        >
        > $ cheetah compile --odir py/ --idir tmpl/ Frame.tmpl
        > Compiling tmpl/Frame.tmpl -> py/tmpl/Frame.py
        > Not what I expected.
        >
        > However:
        > $ cheetah compile --odir py/ --idir tmpl Frame.tmpl
        > Compiling tmpl/Frame.tmpl -> py/Frame.py
        > IOW --idir is sensitive to trailing slashes.
        > I think that's a bug.
        >
        >
        > Bye,
        > Daniel
        >
        >
        > -------------------------------------------------------
        > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
        > files for problems? Stop! Download the new AJAX search engine that makes
        > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
        > http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
        > _______________________________________________
        > Cheetahtemplate-discuss mailing list
        > Cheetahtemplate-discuss@...
        > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss


        -------------------------------------------------------
        This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
        for problems? Stop! Download the new AJAX search engine that makes
        searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
        http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      • Tavis Rudd
        hmm, anyone have objections to turning the ImportHook on by default when running the fill command? ... This SF.net email is sponsored by: Splunk Inc. Do you
        Message 3 of 5 , Dec 16, 2005
          hmm, anyone have objections to turning the ImportHook on by default when
          running the fill command?

          On Friday 16 December 2005 3:01 pm, Tavis Rudd wrote:
          > Hi Daniel,
          > the import issue occurs because Python can't import FrogBase.tmpl. It can
          > only import FrogBase.py, unless you have Cheetah's ImportHooks installed.
          > To work around this limitation when using the 'fill' command you should run
          > 'cheetah compile' first. It will create the required FrogBase.py.
          >
          > The other error you saw with 'cheetah fill Frog1.py' is because Cheetah is
          > expecting Cheetah source files, not Python ones.
          >
          > The final issue with the trailing slashes does look like a bug. I'll look
          > into it next week.
          > Cheers,
          > Tavis
          >
          > On Friday 16 December 2005 11:47 am, Daniel Thaler wrote:
          > > Hi,
          > >
          > > I've just begun trying out cheetah (1.0) and I ran into 2 small oddities:
          > >
          > > 1) I saved the "FrogBase.tmpl" and "Frog1.tmpl" locally for
          > > experimentation. cheetah compile worked as expected and produced the
          > > corresponding .py files. I expected that "cheetah fill Frog1.tmpl" would
          > > then give me html output. What i _got_ was an error:
          > >
          > > $ cheetah fill Frog1.tmpl
          > > [...]
          > > File "/usr/lib/python2.4/site-packages/Cheetah/Template.py", line 446,
          > > in _importAsDummyModule
          > > exec co in mod.__dict__
          > > File "2005121620281428266.py", line 1, in ?
          > > ImportError: No module named FrogBase
          > >
          > > Then I tried
          > > $ cheetah fill Frog1.py
          > > [...]
          > > File "/usr/lib/python2.4/site-packages/Cheetah/Parser.py", line 1817,
          > > in assertEmptyIndentStack
          > > msg="Parsing claims it's done, items remaining on stack: %s" %(
          > > Cheetah.Parser.ParseError:
          > >
          > > Parsing claims it's done, items remaining on stack: def, def, def at line
          > > 203, column 1 in file /home/daniel/dev/cheetah-test/Frog1.py
          > >
          > > Line|Line contents
          > > ----|-------------------------------------------------------------
          > > 200 |## if run from command line:
          > > 201 |if __name__ == '__main__':
          > > 202 | Frog1().runAsMainProgram()
          > > 203 |
          > > ^
          > >
          > > No luck there either.
          > > In the end it turned out not to be a problem because I could get output
          > > by running $ python Frog1.py
          > >
          > > I don't know wether I just didn't understand the documentation or if it's
          > > a bug, but maybe you'd add a few words to the docs about how cheetah fill
          > > is meant to be used? And what use does cheetah fill have when one can
          > > simply run the .py?
          > >
          > >
          > > 2) I then began testing with a fragment of the webpage I hope to use
          > > cheetah for. To keep things tidy I decided to have input and output in
          > > different directories.
          > > So according to the docs I compiled my file Frame.templ like this:
          > >
          > > $ cheetah compile --odir py/ --idir tmpl/ Frame.tmpl
          > > Compiling tmpl/Frame.tmpl -> py/tmpl/Frame.py
          > > Not what I expected.
          > >
          > > However:
          > > $ cheetah compile --odir py/ --idir tmpl Frame.tmpl
          > > Compiling tmpl/Frame.tmpl -> py/Frame.py
          > > IOW --idir is sensitive to trailing slashes.
          > > I think that's a bug.
          > >
          > >
          > > Bye,
          > > Daniel
          > >
          > >
          > > -------------------------------------------------------
          > > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
          > > files for problems? Stop! Download the new AJAX search engine that
          > > makes searching your log files as easy as surfing the web. DOWNLOAD
          > > SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
          > > _______________________________________________
          > > Cheetahtemplate-discuss mailing list
          > > Cheetahtemplate-discuss@...
          > > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
          >
          > -------------------------------------------------------
          > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
          > files for problems? Stop! Download the new AJAX search engine that makes
          > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
          > http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
          > _______________________________________________
          > Cheetahtemplate-discuss mailing list
          > Cheetahtemplate-discuss@...
          > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss


          -------------------------------------------------------
          This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
          for problems? Stop! Download the new AJAX search engine that makes
          searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
          http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        • Mike Orr
          ... Shouldn t be a problem, since templates aren t likely to import modules that use other import hooks. ... Hi Daniel. I wrote the -idir and -odir code. I
          Message 4 of 5 , Dec 17, 2005
            On 12/16/05, Tavis Rudd <tavis@...> wrote:
            > hmm, anyone have objections to turning the ImportHook on by default when
            > running the fill command?

            Shouldn't be a problem, since templates aren't likely to import
            modules that use other import hooks.

            > > > $ cheetah compile --odir py/ --idir tmpl/ Frame.tmpl
            > > > Compiling tmpl/Frame.tmpl -> py/tmpl/Frame.py
            > > > Not what I expected.
            > > >
            > > > However:
            > > > $ cheetah compile --odir py/ --idir tmpl Frame.tmpl
            > > > Compiling tmpl/Frame.tmpl -> py/Frame.py
            > > > IOW --idir is sensitive to trailing slashes.
            > > > I think that's a bug.

            Hi Daniel. I wrote the -idir and -odir code. I never use the
            trailing slash so I must not have noticed that behavior.

            Tavis, add this to CheetahWrapper.ParseOpts before the ._fixExts call
            (line 203):

            if self.opts.idir.endswith('/'):
            self.opts.idir = self.opts.idir[:-1)]
            if self.opts.odir.endswith('/'):
            self.opts.odir = self.opts.odir[:-1]

            Or if one really must support backslashes and colons:

            seps = [x for x in [os.sep, os.altsep] if x]
            for attr in ['idir', 'odir']:
            for sep in seps:
            value = getattr(self, attr)
            if value.endswith(sep):
            value = value[:-len(sep)]
            setattr(self, attr, value)
            break

            --
            Mike Orr <sluggoster@...>
            (mso@... address is semi-reliable)


            -------------------------------------------------------
            This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
            for problems? Stop! Download the new AJAX search engine that makes
            searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
            http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
            _______________________________________________
            Cheetahtemplate-discuss mailing list
            Cheetahtemplate-discuss@...
            https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
          • Tavis Rudd
            btw, I ve applied this patch. ... This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX
            Message 5 of 5 , Dec 29, 2005
              btw, I've applied this patch.

              On Saturday 17 December 2005 11:01 pm, Mike Orr wrote:
              > On 12/16/05, Tavis Rudd <tavis@...> wrote:
              > > hmm, anyone have objections to turning the ImportHook on by default when
              > > running the fill command?
              >
              > Shouldn't be a problem, since templates aren't likely to import
              > modules that use other import hooks.
              >
              > > > > $ cheetah compile --odir py/ --idir tmpl/ Frame.tmpl
              > > > > Compiling tmpl/Frame.tmpl -> py/tmpl/Frame.py
              > > > > Not what I expected.
              > > > >
              > > > > However:
              > > > > $ cheetah compile --odir py/ --idir tmpl Frame.tmpl
              > > > > Compiling tmpl/Frame.tmpl -> py/Frame.py
              > > > > IOW --idir is sensitive to trailing slashes.
              > > > > I think that's a bug.
              >
              > Hi Daniel. I wrote the -idir and -odir code. I never use the
              > trailing slash so I must not have noticed that behavior.
              >
              > Tavis, add this to CheetahWrapper.ParseOpts before the ._fixExts call
              > (line 203):
              >
              > if self.opts.idir.endswith('/'):
              > self.opts.idir = self.opts.idir[:-1)]
              > if self.opts.odir.endswith('/'):
              > self.opts.odir = self.opts.odir[:-1]
              >
              > Or if one really must support backslashes and colons:
              >
              > seps = [x for x in [os.sep, os.altsep] if x]
              > for attr in ['idir', 'odir']:
              > for sep in seps:
              > value = getattr(self, attr)
              > if value.endswith(sep):
              > value = value[:-len(sep)]
              > setattr(self, attr, value)
              > break
              >
              > --
              > Mike Orr <sluggoster@...>
              > (mso@... address is semi-reliable)
              >
              >
              > -------------------------------------------------------
              > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
              > files for problems? Stop! Download the new AJAX search engine that makes
              > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
              > http://ads.osdn.com/?ad_idv37&alloc_id865&op=Click
              > _______________________________________________
              > Cheetahtemplate-discuss mailing list
              > Cheetahtemplate-discuss@...
              > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss


              -------------------------------------------------------
              This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
              for problems? Stop! Download the new AJAX search engine that makes
              searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
              http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
              _______________________________________________
              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.