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

[Cheetahtemplate-discuss] unicode TypeError in Template.py

Expand Messages
  • Joerg Zinke
    hi, a little bug report: cheetah version:cheetah-2.0rc8 python version: 2.4 short description: unicode error is raised/missing unicode check long description:
    Message 1 of 2 , Feb 18, 2008
    • 0 Attachment
      hi,

      a little bug report:

      cheetah version:cheetah-2.0rc8
      python version: 2.4

      short description: unicode error is raised/missing unicode check

      long description:
      we use cheetah together with cherrypy and compile templates on the fly
      with the compiler class.
      if we use the #include directive like this in templates:

      #include os.path.join($_template_path, "default", "header.tmpl")

      with $_template_path as unicode an TypeError is raised in
      compile() function, traceback from cherrypy:

      [...]
      File "/usr/local/lib/python2.4/site-packages/Cheetah/Template.py",
      line 994, in __str__
      def __str__(self): return getattr(self, mainMethName)()
      File "<string>", line 194, in respond
      File "/usr/local/lib/python2.4/site-packages/Cheetah/Template.py",
      line 1524, in _handleCheetahInclude
      nestedTemplateClass = compiler.compile(source=source,file=file)
      File "/usr/local/lib/python2.4/site-packages/Cheetah/Template.py",
      line 743, in compile
      mod = new.module(uniqueModuleName)
      TypeError: module.__init__() argument 1 must be string, not unicode

      ugly workaround:

      in Template.py the moduleName is set from file argument:

      if not moduleName:
      if file and type(file) in StringTypes:
      + file = str(file)
      moduleName = convertTmplPathToModuleName(file)
      __orig_file__ = file
      else:
      moduleName = klass._CHEETAH_defaultModuleNameForTemplates


      I'm not subscribed to the list please cc me.

      regards,

      joerg

      -------------------------------------------------------------------------
      This SF.net email is sponsored by: Microsoft
      Defy all challenges. Microsoft(R) Visual Studio 2008.
      http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Tavis Rudd
      Hi Joerg, This is fixed in the cvs now and will be in the next release. Thanks for reporting it. Tavis ... This SF.net email is sponsored by: Microsoft Defy
      Message 2 of 2 , Mar 9, 2008
      • 0 Attachment
        Hi Joerg,
        This is fixed in the cvs now and will be in the next release.
        Thanks for reporting it.
        Tavis

        On Mon, 18 Feb 2008, Joerg Zinke wrote:

        > hi,
        >
        > a little bug report:
        >
        > cheetah version:cheetah-2.0rc8
        > python version: 2.4
        >
        > short description: unicode error is raised/missing unicode check
        >
        > long description:
        > we use cheetah together with cherrypy and compile templates on the fly
        > with the compiler class.
        > if we use the #include directive like this in templates:
        >
        > #include os.path.join($_template_path, "default", "header.tmpl")
        >
        > with $_template_path as unicode an TypeError is raised in
        > compile() function, traceback from cherrypy:
        >
        > [...]
        > File "/usr/local/lib/python2.4/site-packages/Cheetah/Template.py",
        > line 994, in __str__
        > def __str__(self): return getattr(self, mainMethName)()
        > File "<string>", line 194, in respond
        > File "/usr/local/lib/python2.4/site-packages/Cheetah/Template.py",
        > line 1524, in _handleCheetahInclude
        > nestedTemplateClass = compiler.compile(source=source,file=file)
        > File "/usr/local/lib/python2.4/site-packages/Cheetah/Template.py",
        > line 743, in compile
        > mod = new.module(uniqueModuleName)
        > TypeError: module.__init__() argument 1 must be string, not unicode
        >
        > ugly workaround:
        >
        > in Template.py the moduleName is set from file argument:
        >
        > if not moduleName:
        > if file and type(file) in StringTypes:
        > + file = str(file)
        > moduleName = convertTmplPathToModuleName(file)
        > __orig_file__ = file
        > else:
        > moduleName = klass._CHEETAH_defaultModuleNameForTemplates
        >
        >
        > I'm not subscribed to the list please cc me.
        >
        > regards,
        >
        > joerg
        >
        > -------------------------------------------------------------------------
        > This SF.net email is sponsored by: Microsoft
        > Defy all challenges. Microsoft(R) Visual Studio 2008.
        > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
        > _______________________________________________
        > Cheetahtemplate-discuss mailing list
        > Cheetahtemplate-discuss@...
        > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        >

        -------------------------------------------------------------------------
        This SF.net email is sponsored by: Microsoft
        Defy all challenges. Microsoft(R) Visual Studio 2008.
        http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
        _______________________________________________
        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.