#2351: KeyError: '' in expose if Accept header doesn't match controller content-
type
------------------------+---------------------------------------------------
 Reporter:  corvus      |       Owner:       
     Type:  defect      |      Status:  new  
 Priority:  normal      |   Milestone:       
Component:  TurboGears  |     Version:  2.0.1
 Severity:  normal      |    Keywords:       
------------------------+---------------------------------------------------
 If a poorly behaved client (like a bot) sends an Accept header that does
 not include the content type you have specified that a controller outputs
 via the expose decorator, TurboGears throws an exception.  Erroring out is
 reasonable, however, not handling the exception subjects the developer to
 unwanted notices without informing him or the the operator of the user
 agent of the problem.

 Instead, TG should probably return a 500 with a descriptive text
 indicating the problem.

 To reproduce, create a controller like:

 {{{
     @expose(content_type='application/rss+xml')
     def rss2_0(self, **kw):
         return 'test'
 }}}


 then:


 {{{
 $ telnet localhost 8080
 Trying 127.0.0.1...
 Connected to localhost.localdomain.
 Escape character is '^]'.
 GET /rss2_0 HTTP/1.1
 Accept: text/html

 }}}

 And you'll get an exception like:


 {{{
 File '/usr/local/env/lib/python2.5/site-
 packages/WebError-0.10.1-py2.5.egg/weberror/errormiddleware.py', line 162
 in __call__
   app_iter = self.application(environ, sr_checker)
 File '/usr/local/env/lib/python2.5/site-
 packages/TurboGears2-2.0.1-py2.5.egg/tg/configuration.py', line 643 in
 wrapper
   return app(environ, start_response)
 File '/usr/local/env/lib/python2.5/site-
 packages/TurboGears2-2.0.1-py2.5.egg/tg/configuration.py', line 543 in
 remover
   return app(environ, start_response)
 File '/usr/local/env/lib/python2.5/site-
 packages/repoze.tm2-1.0a4-py2.5.egg/repoze/tm/__init__.py', line 19 in
 __call__
   result = self.application(environ, save_status_and_headers)
 File '/usr/local/env/lib/python2.5/site-
 packages/repoze.who-1.0.10-py2.5.egg/repoze/who/middleware.py', line 107
 in __call__
   app_iter = app(environ, wrapper.wrap_start_response)
 File '/usr/local/env/lib/python2.5/site-
 packages/ToscaWidgets-0.9.7.2-py2.5.egg/tw/core/middleware.py', line 36 in
 __call__
   return self.wsgi_app(environ, start_response)
 File '/usr/local/env/lib/python2.5/site-
 packages/ToscaWidgets-0.9.7.2-py2.5.egg/tw/core/middleware.py', line 59 in
 wsgi_app
   resp = req.get_response(self.application)
 File 'build/bdist.linux-i686/egg/webob/__init__.py', line 1325 in
 get_response
 File 'build/bdist.linux-i686/egg/webob/__init__.py', line 1293 in
 call_application
 File '/usr/local/env/lib/python2.5/site-
 packages/ToscaWidgets-0.9.7.2-py2.5.egg/tw/core/resource_injector.py',
 line 67 in _injector
   resp = req.get_response(app)
 File 'build/bdist.linux-i686/egg/webob/__init__.py', line 1325 in
 get_response
 File 'build/bdist.linux-i686/egg/webob/__init__.py', line 1293 in
 call_application
 File '/usr/local/env/lib/python2.5/site-
 packages/Beaker-1.3-py2.5.egg/beaker/middleware.py', line 81 in __call__
   return self.app(environ, start_response)
 File '/usr/local/env/lib/python2.5/site-
 packages/Beaker-1.3-py2.5.egg/beaker/middleware.py', line 160 in __call__
   return self.wrap_app(environ, session_start_response)
 File '/usr/local/env/lib/python2.5/site-
 packages/Routes-1.10.3-py2.5.egg/routes/middleware.py', line 130 in
 __call__
   response = self.app(environ, start_response)
 File '/usr/local/env/lib/python2.5/site-
 packages/Pylons-0.9.7-py2.5.egg/pylons/wsgiapp.py', line 125 in __call__
   response = self.dispatch(controller, environ, start_response)
 File '/usr/local/env/lib/python2.5/site-
 packages/Pylons-0.9.7-py2.5.egg/pylons/wsgiapp.py', line 324 in dispatch
   return controller(environ, start_response)
 File '/usr/local/env/app/app/lib/base.py', line 32 in __call__
   return TGController.__call__(self, environ, start_response)
 File '/usr/local/env/lib/python2.5/site-
 packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py', line 221 in
 __call__
   response = self._dispatch_call()
 File '/usr/local/env/lib/python2.5/site-
 packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py', line 172 in
 _dispatch_call
   response = self._inspect_call(func)
 File '/usr/local/env/lib/python2.5/site-
 packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py', line 107 in
 _inspect_call
   result = self._perform_call(func, args)
 File '/usr/local/env/lib/python2.5/site-
 packages/TurboGears2-2.0.1-py2.5.egg/tg/controllers.py', line 836 in
 _perform_call
   self, controller, params, remainder=remainder)
 File '/usr/local/env/lib/python2.5/site-
 packages/TurboGears2-2.0.1-py2.5.egg/tg/controllers.py', line 182 in
 _perform_call
   response = self._render_response(controller, output)
 File '/usr/local/env/lib/python2.5/site-
 packages/TurboGears2-2.0.1-py2.5.egg/tg/controllers.py', line 294 in
 _render_response
   controller.decoration.lookup_template_engine(pylons.request)
 File '/usr/local/env/lib/python2.5/site-
 packages/TurboGears2-2.0.1-py2.5.egg/tg/decorators.py', line 138 in
 lookup_template_engine
   engine, template, exclude_names = self.engines[content_type]
 KeyError: ''

 }}}

-- 
Ticket URL: <http://trac.turbogears.org/ticket/2351>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to