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

chameleon: semi misleading template error messages #3232

Closed
castilma opened this issue Feb 15, 2018 · 3 comments
Closed

chameleon: semi misleading template error messages #3232

castilma opened this issue Feb 15, 2018 · 3 comments

Comments

@castilma
Copy link

castilma commented Feb 15, 2018

I'm not sure if this is the right place for this.

if you run the attached 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 think you only need chameleon, waitress and pyramid to run this project.
bad_err.tar.gz

@digitalresistor
Copy link
Member

I'd recommend creating a new GitHub repo with your code in it, so it can be reviewed without downloading a tarball.

Second, I'd recommend opening an issue in the chameleon repository, I don't believe this is an issue with Pyramid.

@digitalresistor
Copy link
Member

@castilma
Copy link
Author

I reported it there. malthe/chameleon#259

strangely the error message is better, when I install pyramid and chameleon from nix...

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

No branches or pull requests

2 participants