This also harms when working with gettext translations, to extract
translatable strings from template files (using babel), I have to
generate python code from it, and then use the default extractor for
python files.
at fist my extract_webpy function looked like this:
def extract_webpy(fileobj, keywords, comment_tags, options):
code = "# coding: utf-8\n\n" +
Template.generate_code(fileobj.read(), fileobj.name)
return extract_python(StringIO.StringIO(code), keywords,
comment_tags, options)
But accidently it stopped to work, because of generate_code raising
UnicodeDecode error.
So now it should be:
def extract_webpy(fileobj, keywords, comment_tags, options):
code = "# coding: utf-8\n\n" +
Template.generate_code(fileobj.read().decode("utf-8"), fileobj.name)
return extract_python(StringIO.StringIO(code), keywords,
comment_tags, options)
On Jun 18, 11:57 pm, andrei <[email protected]> wrote:
> I would like to hear a word from the developers on this issue, I
> consider it to be essential.
>
> Defining variables using escape sequences in templates is not an
> option.
>
> On Jun 16, 7:30 pm, andrei <[email protected]> wrote:
>
>
>
> > I've managed to fix this issue, in the template.py, line: 1011.
>
> > I changed:
> > return Template(open(path).read(), filename=path,
> > **self._keywords)
> > to:
> > return Template(open(path).read().decode("utf-8"), filename=path,
> > **self._keywords)
>
> > I wonder if this can be optional setting.
>
> > On Jun 16, 6:59 pm, andrei <[email protected]> wrote:
>
> > > I code in TextMate, that is set to create files in UTF-8 by default.
>
> > > The problem I think is that the code of compiled Template isn't utf-8
> > > encoded.
>
> > > On Jun 16, 3:23 pm, James <[email protected]> wrote:
>
> > > > Make sure the actual template is saved as a utf-8 encoded file.
>
> > > > On Jun 14, 5:31 am, andrei <[email protected]> wrote:
>
> > > > > This raises UnicodeDecodeError:
>
> > > > > test.py:
>
> > > > > import web, os
> > > > > render =
> > > > > web.template.render(os.path.abspath(os.path.dirname(__file__)))
> > > > > render.test()
>
> > > > > test.html:
>
> > > > > $var array = ["ÏÄÉÎ","Ä×Á","ÔÒÉ"]
> > > > > $ test = "ÔÅËÓÔ"
> > > > > <p>just a test</p>
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.