Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(semi fixed?) misleading template error messages. (only some versions) #259

Open
castilma opened this issue Feb 16, 2018 · 3 comments
Open
Labels

Comments

@castilma
Copy link

castilma commented Feb 16, 2018

if you run this server and visit localhost:8080/myroute/foo, you get a template error:

will now serve on port  8080
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/tweens.py", line 12, in _error_handler
    response = request.invoke_exception_view(exc_info)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/view.py", line 756, in invoke_exception_view
    raise HTTPNotFound
pyramid.httpexceptions.HTTPNotFound: The resource could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/router.py", line 270, in __call__
    response = self.execution_policy(environ, self)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/router.py", line 278, in default_execution_policy
    return request.invoke_exception_view(reraise=True)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/view.py", line 755, in invoke_exception_view
    reraise_(*exc_info)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/compat.py", line 148, in reraise
    raise value
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/router.py", line 276, in default_execution_policy
    return router.invoke_request(request)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/router.py", line 249, in invoke_request
    response = handle_request(request)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/tweens.py", line 41, in excview_tween
    response = _error_handler(request, exc)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/tweens.py", line 16, in _error_handler
    reraise(*exc_info)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/compat.py", line 148, in reraise
    raise value
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/tweens.py", line 39, in excview_tween
    response = handler(request)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/router.py", line 156, in handle_request
    view_name
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/view.py", line 642, in _call_view
    response = view_callable(context, request)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/viewderivers.py", line 462, in rendered_view
    request, result, view_inst, context)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/renderers.py", line 435, in render_view
    return self.render_to_response(response, system, request=request)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/renderers.py", line 458, in render_to_response
    result = self.render(value, system_values, request=request)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid/renderers.py", line 454, in render
    result = renderer(value, system_values)
  File "/home/pi/.local/lib/python3.5/site-packages/pyramid_chameleon/zpt.py", line 47, in __call__
    result = self.template(**system)
  File "/home/pi/.local/lib/python3.5/site-packages/chameleon/template.py", line 124, in __call__
    return self.render(**kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/chameleon/zpt/template.py", line 297, in render
    return super(PageTemplate, self).render(**_kw)
  File "/home/pi/.local/lib/python3.5/site-packages/chameleon/template.py", line 191, in render
    raise_with_traceback(exc, tb)
  File "/home/pi/.local/lib/python3.5/site-packages/chameleon/utils.py", line 75, in raise_with_traceback
    raise exc
  File "/home/pi/.local/lib/python3.5/site-packages/chameleon/template.py", line 171, in render
    self._render(stream, econtext, rcontext)
  File "index_161d98e17b5a3f24d86304929b34b0af.py", line 200, in render
  File "/home/pi/.local/lib/python3.5/site-packages/chameleon/zpt/template.py", line 301, in include
    self._render(*args, **kwargs)
  File "base_9068126ef4690e8b4198d76bc88e1dfb.py", line 305, in render
  File "index_161d98e17b5a3f24d86304929b34b0af.py", line 136, in __fill_content
  File "/home/pi/.local/lib/python3.5/site-packages/chameleon/utils.py", line 406, in __getitem__
    raise NameError(key)
NameError: undecl_name

 - Expression: "pair[0]"
 - Filename:   /home/pi/code/pathbug/project/templates/base.pt
 - Location:   (line 14: col 75)
 - Source:     ... oute/${pair[1]}" tal:content="pair[0]" /></li>
                                                 ^^^^^^^
 - Expression: "load: base.pt"
 - Filename:   /home/pi/code/pathbug/project/templates/index.pt
 - Location:   (line 1: col 23)
 - Source:     <metal:main use-macro="load: base.pt">
                                      ^^^^^^^^^^^^^
 - Arguments:  get_csrf_token: <partial - at 0x75deab70>
               content: some spec content
               request: <Request - at 0x75dd4b90>
               repeat: {...} (0)
               current_spec: sec
               view: <function art_desc at 0x75dd38e8>
               target_language: <NoneType - at 0x3e5788>
               macroname: load: base.pt
               context: <DefaultRootFactory None at 0x75dd4bb0>
               renderer_name: templates/index.pt
               renderer_info: <RendererHelper - at 0x75dd4e50>
               req: <Request - at 0x75dd4b90>
               tuples: <list - at 0x75e47328>
192.168.178.5 - - [16/Feb/2018 00:07:10] "GET /myroute/sec HTTP/1.1" 500 59

the problem is the 'undecl_name' in the file templates/index.pt. The NameError mentions that, but the following info is misleading. It looks like the error is in base.pt in the expression pair[0]. but that is not the case!

I have to say, that I get this misleading error message only on a raspberry pi. here is the output of pip show:

Chameleon (3.2)
cryptography (1.7.1)
Cython (0.26)
hupper (1.0)
idna (2.2)
keyring (10.1)
keyrings.alt (1.3)
numpy (1.12.1)
PasteDeploy (1.5.2)
Pillow (4.0.0)
pip (9.0.1)
plaster (1.0)
plaster-pastedeploy (0.4.2)
pyasn1 (0.1.9)
pycrypto (2.6.1)
Pygments (2.2.0)
pygobject (3.22.0)
pyramid (1.9.1)
pyramid-chameleon (0.3)
python-apt (1.1.0b5)
pyxdg (0.25)
repoze.lru (0.7)
SecretStorage (2.3.1)
setuptools (38.5.1)
six (1.10.0)
translationstring (1.3)
unattended-upgrades (0.1)
venusian (1.1.0)
waitress (1.1.0)
WebOb (1.8.0rc1)
wheel (0.29.0)
zope.deprecation (4.3.0)
zope.interface (4.4.3)

on nixos with nix-shell -p python36Packages.pyramid -p python36Packages.cookiecutter -p python36Packages.waitress -p python36Packages.pyramid_chameleon, the error message is not misleading:

Traceback (most recent call last):
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/tweens.py", line 12, in _error_handler
    response = request.invoke_exception_view(exc_info)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/view.py", line 756, in invoke_exception_view
    raise HTTPNotFound
pyramid.httpexceptions.HTTPNotFound: The resource could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/z1avajv6hrjcx9nb07x9nd6cklb45w2r-python3-3.6.4/lib/python3.6/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/router.py", line 270, in __call__
    response = self.execution_policy(environ, self)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/router.py", line 278, in default_execution_policy
    return request.invoke_exception_view(reraise=True)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/view.py", line 755, in invoke_exception_view
    reraise_(*exc_info)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/compat.py", line 148, in reraise
    raise value
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/router.py", line 276, in default_execution_policy
    return router.invoke_request(request)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/router.py", line 249, in invoke_request
    response = handle_request(request)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/tweens.py", line 41, in excview_tween
    response = _error_handler(request, exc)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/tweens.py", line 16, in _error_handler
    reraise(*exc_info)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/compat.py", line 148, in reraise
    raise value
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/tweens.py", line 39, in excview_tween
    response = handler(request)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/router.py", line 156, in handle_request
    view_name
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/view.py", line 642, in _call_view
    response = view_callable(context, request)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/viewderivers.py", line 462, in rendered_view
    request, result, view_inst, context)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/renderers.py", line 435, in render_view
    return self.render_to_response(response, system, request=request)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/renderers.py", line 458, in render_to_response
    result = self.render(value, system_values, request=request)
  File "/nix/store/gda1y88nj01wm23mr5ymwdygwbkcg20q-python3.6-pyramid-1.9.1/lib/python3.6/site-packages/pyramid/renderers.py", line 454, in render
    result = renderer(value, system_values)
  File "/nix/store/bp5ckki3qmn908kzi10v9hy7qvmldc79-python3.6-pyramid_chameleon-0.3/lib/python3.6/site-packages/pyramid_chameleon/zpt.py", line 47, in __call__
    result = self.template(**system)
  File "/nix/store/jl484syhb8yzgkxdblg2i7dfli33bkig-python3.6-Chameleon-2.25/lib/python3.6/site-packages/chameleon/template.py", line 124, in __call__
    return self.render(**kwargs)
  File "/nix/store/jl484syhb8yzgkxdblg2i7dfli33bkig-python3.6-Chameleon-2.25/lib/python3.6/site-packages/chameleon/zpt/template.py", line 261, in render
    return super(PageTemplate, self).render(**vars)
  File "/nix/store/jl484syhb8yzgkxdblg2i7dfli33bkig-python3.6-Chameleon-2.25/lib/python3.6/site-packages/chameleon/template.py", line 191, in render
    raise_with_traceback(exc, tb)
  File "/nix/store/jl484syhb8yzgkxdblg2i7dfli33bkig-python3.6-Chameleon-2.25/lib/python3.6/site-packages/chameleon/utils.py", line 75, in raise_with_traceback
    raise exc
  File "/nix/store/jl484syhb8yzgkxdblg2i7dfli33bkig-python3.6-Chameleon-2.25/lib/python3.6/site-packages/chameleon/template.py", line 171, in render
    self._render(stream, econtext, rcontext)
  File "index_3612173be5b84f0f49f78e49664f6700.py", line 187, in render
  File "/nix/store/jl484syhb8yzgkxdblg2i7dfli33bkig-python3.6-Chameleon-2.25/lib/python3.6/site-packages/chameleon/zpt/template.py", line 265, in include
    self._render(*args, **kwargs)
  File "base_4b530c1718bcb6334b096e47679d39d6.py", line 300, in render
  File "index_3612173be5b84f0f49f78e49664f6700.py", line 130, in __fill_content
  File "/nix/store/jl484syhb8yzgkxdblg2i7dfli33bkig-python3.6-Chameleon-2.25/lib/python3.6/site-packages/chameleon/utils.py", line 406, in __getitem__
    raise NameError(key)
NameError: undecl_name

 - Expression: "undecl_name"
 - Filename:   /home/mcd/tmp/project/rep/project/templates/index.pt
 - Location:   (line 6: col 58)
 - Source:     ... pec | nothing" tal:content="undecl_name" />
                                               ^^^^^^^^^^^
 - Arguments:  view: <function art_desc at 0x7f4ab51a5a60>
               renderer_name: templates/index.pt
               renderer_info: <RendererHelper - at 0x7f4ab50d2320>
               context: <DefaultRootFactory None at 0x7f4ab5197ba8>
               request: <Request - at 0x7f4ab5189d68>
               req: <Request - at 0x7f4ab5189d68>
               get_csrf_token: <partial - at 0x7f4ab5174138>
               content: some spec content
               tuples: <list - at 0x7f4ab5192a88>
               current_spec: sec
               repeat: {...} (0)
127.0.0.1 - - [16/Feb/2018 13:14:13] "GET /myroute/sec HTTP/1.1" 500 59

I report this, because the versions seem to be the same (look here): pyramid 1.9.1 and pyramid_chameleon 0.3. So I'm not sure if you fixed the error reporting, or if it broke recently.

@malthe
Copy link
Owner

malthe commented Feb 16, 2018

There is some problem currently with error messages – I have seen the same. I'm going to try and find time to look at it in detail.

Should be an easy fix, once identified.

@malthe malthe added the core label Feb 16, 2018
@malthe
Copy link
Owner

malthe commented May 8, 2018

Does this pull request fix your issue:

#261 – ?

@castilma
Copy link
Author

castilma commented May 8, 2018

no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants