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

[Cheetahtemplate-discuss] Quote pb .

Expand Messages
  • Jérome Kerdreux
    First at all : Hy all, and thanks for this beautifull module :) So I use cheetah as a parser to generate some zope piece of code. I got some cheetah template
    Message 1 of 2 , Nov 2, 2001
      First at all :

      Hy all, and thanks for this beautifull module :)


      So I use cheetah as a parser to generate some zope piece of code.
      I got some cheetah template that have .py structure and fill the code
      at the code generation. But I get some errors w/ the quote. cause in
      fact I need to do things like this

      ==========================
      # code generated by cheetah
      fti = { 'id' : '$entity_name',
      'content .. ' .

      }
      ==========================
      As you see in this template example, I need to have a two quote. And
      this makes cheetah crash cause it do ''' \'id\' .. which just crash python
      due to wrong quoted string.

      So I patched cheetah in Compiler.py like this
      ===================================================
      336a337,345
      > # Hack big / jkx
      > # Do this to avoid \' pb
      > def quote_chunk(self, chunk):
      > if len(chunk)>6:
      > chunk=chunk[0:3]+chunk[3:-3].replace("\\'", "'")+chunk[-3:]
      > chunk=chunk[0:3]+chunk[3:-3].replace("'", "\\'")+chunk[-3:]
      > #print "[%s]" % chunk
      > return chunk
      >
      338c347,348
      < self.addChunk('write(' + chunk + ")")
      ---
      > self.addChunk('write (' + self.quote_chunk(chunk) + ")")
      ==================================================

      As you can see this is really a quick and dirty hack that check out the
      quote for every chunk.

      Could some one fix that in the next release ? or is it already done in
      a cvs version ?

      Thanks for the help :)

      /Regards







      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Tavis Rudd
      ... thanks! ... I was fairly sure that we d caught all the quoting issues, but then we added a new method to make longer strings look nicer in the generated
      Message 2 of 2 , Nov 2, 2001
        On Friday 02 November 2001 01:24, Jérome Kerdreux wrote:
        > First at all :
        >
        > Hy all, and thanks for this beautifull module :)

        thanks!


        > So I use cheetah as a parser to generate some zope piece of code.
        > I got some cheetah template that have .py structure and fill the
        > code at the code generation. But I get some errors w/ the quote.
        > cause in fact I need to do things like this

        I was fairly sure that we'd caught all the quoting issues, but then
        we added a new method to make longer strings look nicer in the
        generated source code ... and forgot to add the appropriate test
        cases for it. oops.

        It's fixed in the CVS now. There should be a new alpha release out
        in a week or so.

        Cheers,
        Tavis


        _______________________________________________
        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.