Discussion:
[TurboGears] Can't use — in template
Mikhail
2018-01-03 16:25:07 UTC
Permalink
Hello everyone!

I'm having trouble with adding &mdash to any template.

I'm started with gearbox quickstart project and edited generated template
by adding a single block of text just in the begining of <body> section:

<body py:block="body" py:strip="True">

Hello &mdash; world!

When trying to open corrsponded page I get error. Here is most relevant
part of it:


- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/wsgiapp.py",
line *120*, in __call__

response = self.wrapped_dispatch(controller, environ, context)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/errorpage.py"
, line *63*, in __call__

resp = self.next_handler(controller, environ, context)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/transaction_manager.py"
, line *103*, in __call__

reraise(*exc_info)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/_compat.py",
line *87*, in reraise

raise value

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/transaction_manager.py"
, line *79*, in __call__

response = self.next_handler(controller, environ, context)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/identity.py"
, line *75*, in __call__

return self.next_handler(controller, environ, context)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/i18n.py"
, line *71*, in __call__

return self.next_handler(controller, environ, context)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/wsgiapp.py",
line *285*, in _dispatch

return controller(environ, context)

- File "/home/uni/projects/cafealpha/cafealpha/lib/base.py", line *27*,
in __call__

return TGController.__call__(self, environ, context)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/controllers/dispatcher.py"
, line *119*, in __call__

response = self._perform_call(context)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/controllers/dispatcher.py"
, line *108*, in _perform_call

r = self._call(action, params, remainder=remainder, context=context)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/controllers/decoratedcontroller.py"
, line *125*, in _call

response = self._render_response(context, controller, output)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/controllers/decoratedcontroller.py"
, line *235*, in _render_response

template_name=template_name, **render_params)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/render.py", line
*208*, in render

kwargs['result'] = render_function(template_name, tg_vars, **kwargs)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/renderers/kajiki.py"
, line *98*, in __call__

cache_expire=cache_expire)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/render.py", line
*274*, in cached_template

return render_func()

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/renderers/kajiki.py"
, line *93*, in render_template

template = self.loader.load(template_name, **render_params)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/loader.py",
line *78*, in import_

return super(FileLoader, self).import_(name, *args, **kwargs)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/loader.py",
line *21*, in import_

mod = self._load(name, *args, **kwargs)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/loader.py",
line *100*, in _load

*args, **options)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/xml_template.py"
, line *52*, in XMLTemplate

doc = _Parser(filename, source).parse()

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/xml_template.py"
, line *593*, in parse

parser.parse(source)

- File "/usr/lib64/python3.4/xml/sax/expatreader.py", line *110*, in
parse

xmlreader.IncrementalParser.parse(self, source)

- File "/usr/lib64/python3.4/xml/sax/xmlreader.py", line *123*, in parse

self.feed(buffer)

- File "/usr/lib64/python3.4/xml/sax/expatreader.py", line *210*, in feed

self._parser.Parse(data, isFinal)

- File "/home/abuild/rpmbuild/BUILD/Python-3.4.6/Modules/pyexpat.c", line
*599*, in SkippedEntity
- File "/usr/lib64/python3.4/xml/sax/expatreader.py", line *416*, in
skipped_entity_handler

self._cont_handler.skippedEntity(name)

- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/xml_template.py"
, line *639*, in skippedEntity

return self.characters(html5[name])


KeyError: 'mdash'



It is looks like template engine (Kajiki) is trying to find replacement for
'mdash' and fails.
And there is no mdash in html[] array, but 'mdash;' with semicolon

If i manually edit html5[] to include mdash without semicolon it works and
renders as expected.

*So here is question*: what am I done wrong? Is something on my end
truncates semicolon in addition to ampersand.

--
With best New Year wishes. Mikhail.
--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.
jeetu
2018-01-03 16:47:59 UTC
Permalink
Hi Mikhail,
Why don't you just write unicode char directly. I use pycharm editor and
python3, which supports unicode seemlessly. Try copy pasting following line

Hello — world!

I tried and it works!
Post by Mikhail
Hello everyone!
I'm having trouble with adding &mdash to any template.
I'm started with gearbox quickstart project and edited generated template
<body py:block="body" py:strip="True">
Hello &mdash; world!
When trying to open corrsponded page I get error. Here is most relevant
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/wsgiapp.py",
line *120*, in __call__
response = self.wrapped_dispatch(controller, environ, context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/errorpage.py"
, line *63*, in __call__
resp = self.next_handler(controller, environ, context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/transaction_manager.py"
, line *103*, in __call__
reraise(*exc_info)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/_compat.py",
line *87*, in reraise
raise value
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/transaction_manager.py"
, line *79*, in __call__
response = self.next_handler(controller, environ, context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/identity.py"
, line *75*, in __call__
return self.next_handler(controller, environ, context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/i18n.py"
, line *71*, in __call__
return self.next_handler(controller, environ, context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/wsgiapp.py",
line *285*, in _dispatch
return controller(environ, context)
- File "/home/uni/projects/cafealpha/cafealpha/lib/base.py", line *27*,
in __call__
return TGController.__call__(self, environ, context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/controllers/dispatcher.py"
, line *119*, in __call__
response = self._perform_call(context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/controllers/dispatcher.py"
, line *108*, in _perform_call
r = self._call(action, params, remainder=remainder, context=context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/controllers/decoratedcontroller.py"
, line *125*, in _call
response = self._render_response(context, controller, output)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/controllers/decoratedcontroller.py"
, line *235*, in _render_response
template_name=template_name, **render_params)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/render.py",
line *208*, in render
kwargs['result'] = render_function(template_name, tg_vars, **kwargs)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/renderers/kajiki.py"
, line *98*, in __call__
cache_expire=cache_expire)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/render.py",
line *274*, in cached_template
return render_func()
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/renderers/kajiki.py"
, line *93*, in render_template
template = self.loader.load(template_name, **render_params)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/loader.py"
, line *78*, in import_
return super(FileLoader, self).import_(name, *args, **kwargs)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/loader.py"
, line *21*, in import_
mod = self._load(name, *args, **kwargs)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/loader.py"
, line *100*, in _load
*args, **options)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/xml_template.py"
, line *52*, in XMLTemplate
doc = _Parser(filename, source).parse()
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/xml_template.py"
, line *593*, in parse
parser.parse(source)
- File "/usr/lib64/python3.4/xml/sax/expatreader.py", line *110*, in
parse
xmlreader.IncrementalParser.parse(self, source)
- File "/usr/lib64/python3.4/xml/sax/xmlreader.py", line *123*, in parse
self.feed(buffer)
- File "/usr/lib64/python3.4/xml/sax/expatreader.py", line *210*, in feed
self._parser.Parse(data, isFinal)
- File "/home/abuild/rpmbuild/BUILD/Python-3.4.6/Modules/pyexpat.c",
line *599*, in SkippedEntity
- File "/usr/lib64/python3.4/xml/sax/expatreader.py", line *416*, in
skipped_entity_handler
self._cont_handler.skippedEntity(name)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/xml_template.py"
, line *639*, in skippedEntity
return self.characters(html5[name])
KeyError: 'mdash'
It is looks like template engine (Kajiki) is trying to find replacement
for 'mdash' and fails.
And there is no mdash in html[] array, but 'mdash;' with semicolon
If i manually edit html5[] to include mdash without semicolon it works and
renders as expected.
*So here is question*: what am I done wrong? Is something on my end
truncates semicolon in addition to ampersand.
--
With best New Year wishes. Mikhail.
--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.
jeetu
2018-01-03 16:51:31 UTC
Permalink
Try replacing your index.html with the attached one.
Post by Mikhail
Hello everyone!
I'm having trouble with adding &mdash to any template.
I'm started with gearbox quickstart project and edited generated template
<body py:block="body" py:strip="True">
Hello &mdash; world!
When trying to open corrsponded page I get error. Here is most relevant
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/wsgiapp.py",
line *120*, in __call__
response = self.wrapped_dispatch(controller, environ, context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/errorpage.py"
, line *63*, in __call__
resp = self.next_handler(controller, environ, context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/transaction_manager.py"
, line *103*, in __call__
reraise(*exc_info)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/_compat.py",
line *87*, in reraise
raise value
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/transaction_manager.py"
, line *79*, in __call__
response = self.next_handler(controller, environ, context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/identity.py"
, line *75*, in __call__
return self.next_handler(controller, environ, context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/appwrappers/i18n.py"
, line *71*, in __call__
return self.next_handler(controller, environ, context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/wsgiapp.py",
line *285*, in _dispatch
return controller(environ, context)
- File "/home/uni/projects/cafealpha/cafealpha/lib/base.py", line *27*,
in __call__
return TGController.__call__(self, environ, context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/controllers/dispatcher.py"
, line *119*, in __call__
response = self._perform_call(context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/controllers/dispatcher.py"
, line *108*, in _perform_call
r = self._call(action, params, remainder=remainder, context=context)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/controllers/decoratedcontroller.py"
, line *125*, in _call
response = self._render_response(context, controller, output)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/controllers/decoratedcontroller.py"
, line *235*, in _render_response
template_name=template_name, **render_params)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/render.py",
line *208*, in render
kwargs['result'] = render_function(template_name, tg_vars, **kwargs)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/renderers/kajiki.py"
, line *98*, in __call__
cache_expire=cache_expire)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/render.py",
line *274*, in cached_template
return render_func()
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/tg/renderers/kajiki.py"
, line *93*, in render_template
template = self.loader.load(template_name, **render_params)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/loader.py"
, line *78*, in import_
return super(FileLoader, self).import_(name, *args, **kwargs)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/loader.py"
, line *21*, in import_
mod = self._load(name, *args, **kwargs)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/loader.py"
, line *100*, in _load
*args, **options)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/xml_template.py"
, line *52*, in XMLTemplate
doc = _Parser(filename, source).parse()
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/xml_template.py"
, line *593*, in parse
parser.parse(source)
- File "/usr/lib64/python3.4/xml/sax/expatreader.py", line *110*, in
parse
xmlreader.IncrementalParser.parse(self, source)
- File "/usr/lib64/python3.4/xml/sax/xmlreader.py", line *123*, in parse
self.feed(buffer)
- File "/usr/lib64/python3.4/xml/sax/expatreader.py", line *210*, in feed
self._parser.Parse(data, isFinal)
- File "/home/abuild/rpmbuild/BUILD/Python-3.4.6/Modules/pyexpat.c",
line *599*, in SkippedEntity
- File "/usr/lib64/python3.4/xml/sax/expatreader.py", line *416*, in
skipped_entity_handler
self._cont_handler.skippedEntity(name)
- File
"/home/uni/projects/tgenv/lib/python3.4/site-packages/kajiki/xml_template.py"
, line *639*, in skippedEntity
return self.characters(html5[name])
KeyError: 'mdash'
It is looks like template engine (Kajiki) is trying to find replacement
for 'mdash' and fails.
And there is no mdash in html[] array, but 'mdash;' with semicolon
If i manually edit html5[] to include mdash without semicolon it works and
renders as expected.
*So here is question*: what am I done wrong? Is something on my end
truncates semicolon in addition to ampersand.
--
With best New Year wishes. Mikhail.
--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.
Loading...