#2134: tg_format not working
------------------------+---------------------------------------------------
 Reporter:  percious    |       Owner:  faide
     Type:  defect      |      Status:  new  
 Priority:  high        |   Milestone:  2.0b3
Component:  TurboGears  |     Version:  trunk
 Severity:  major       |    Keywords:       
------------------------+---------------------------------------------------
 tg_format is throwing some kind of mime type error as follows:
 {{{
 URL: http://localhost:8080/admin/users?tg_format=json
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/WebError-0.9.1-py2.5.egg/weberror/evalexception.py', line 428 in
 respond
   app_iter = self.application(environ, detect_start_response)
 File '/Users/percious/oss/tgdev/src/tg2/tg/configuration.py', line 525 in
 remover
   return app(environ, start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/repoze.tm2-1.0a3-py2.5.egg/repoze/tm/__init__.py', line 19 in
 __call__
   result = self.application(environ, save_status_and_headers)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/repoze.who-1.0.9-py2.5.egg/repoze/who/middleware.py', line 107 in
 __call__
   app_iter = app(environ, wrapper.wrap_start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/ToscaWidgets-0.9.5dev_20081026-py2.5.egg/tw/core/middleware.py',
 line 36 in __call__
   return self.wsgi_app(environ, start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/ToscaWidgets-0.9.5dev_20081026-py2.5.egg/tw/core/middleware.py',
 line 59 in wsgi_app
   resp = req.get_response(self.application)
 File 'build/bdist.macosx-10.3-i386/egg/webob/__init__.py', line 1307 in
 get_response
 File 'build/bdist.macosx-10.3-i386/egg/webob/__init__.py', line 1275 in
 call_application
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 
packages/ToscaWidgets-0.9.5dev_20081026-py2.5.egg/tw/core/resource_injector.py',
 line 67 in _injector
   resp = req.get_response(app)
 File 'build/bdist.macosx-10.3-i386/egg/webob/__init__.py', line 1307 in
 get_response
 File 'build/bdist.macosx-10.3-i386/egg/webob/__init__.py', line 1275 in
 call_application
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Beaker-1.1.2-py2.5.egg/beaker/middleware.py', line 81 in __call__
   return self.app(environ, start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Beaker-1.1.2-py2.5.egg/beaker/middleware.py', line 159 in
 __call__
   return self.wrap_app(environ, session_start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Routes-1.10.1-py2.5.egg/routes/middleware.py', line 118 in
 __call__
   response = self.app(environ, start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Pylons-0.9.7rc4-py2.5.egg/pylons/wsgiapp.py', line 117 in
 __call__
   response = self.dispatch(controller, environ, start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Pylons-0.9.7rc4-py2.5.egg/pylons/wsgiapp.py', line 316 in
 dispatch
   return controller(environ, start_response)
 File '/Users/percious/oss/tgdev/src/tgtest/tgtest/lib/base.py', line 36 in
 __call__
   return TGController.__call__(self, environ, start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Pylons-0.9.7rc4-py2.5.egg/pylons/controllers/core.py', line 204
 in __call__
   response = self._dispatch_call()
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Pylons-0.9.7rc4-py2.5.egg/pylons/controllers/core.py', line 159
 in _dispatch_call
   response = self._inspect_call(func)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Pylons-0.9.7rc4-py2.5.egg/pylons/controllers/core.py', line 95 in
 _inspect_call
   result = self._perform_call(func, args)
 File '/Users/percious/oss/tgdev/src/tg2/tg/controllers.py', line 508 in
 _perform_call
   self, controller, params, remainder=remainder)
 File '/Users/percious/oss/tgdev/src/tg2/tg/controllers.py', line 118 in
 _perform_call
   response = self._render_response(controller, output)
 File '/Users/percious/oss/tgdev/src/tg2/tg/controllers.py', line 222 in
 _render_response
   controller.decoration.lookup_template_engine(pylons.request)
 File '/Users/percious/oss/tgdev/src/tg2/tg/decorators.py', line 104 in
 lookup_template_engine
   assert '/' in tg_format, 'Invalid tg_format: must be a MIME type'
 AssertionError: Invalid tg_format: must be a MIME type
 }}}

 here is a look at my controller function:
 {{{
     @expose('tgtest.templates.admin.users')
     @expose('json')
     def users(self, tg_format='html', **kw):
         if tg_format=='application/javascript':
             pylons.response.content_type = 'json'
             return user_table_filler.get_value(**kw)
         pylons.c.widget = user_table
         return dict()
 }}}

 this is an important one since the docs use this technique:
 http://turbogears.org/2.0/docs/main/Wiki20/JSONMochiKit.html?highlight=json

 Also, if you pass in tg_format=application/javascript, you get this
 marvelous dump:

 {{{
 URL: http://localhost:8080/admin/users?tg_format=application/javascript
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/WebError-0.9.1-py2.5.egg/weberror/evalexception.py', line 428 in
 respond
   app_iter = self.application(environ, detect_start_response)
 File '/Users/percious/oss/tgdev/src/tg2/tg/configuration.py', line 525 in
 remover
   return app(environ, start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/repoze.tm2-1.0a3-py2.5.egg/repoze/tm/__init__.py', line 19 in
 __call__
   result = self.application(environ, save_status_and_headers)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/repoze.who-1.0.9-py2.5.egg/repoze/who/middleware.py', line 107 in
 __call__
   app_iter = app(environ, wrapper.wrap_start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/ToscaWidgets-0.9.5dev_20081026-py2.5.egg/tw/core/middleware.py',
 line 36 in __call__
   return self.wsgi_app(environ, start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/ToscaWidgets-0.9.5dev_20081026-py2.5.egg/tw/core/middleware.py',
 line 59 in wsgi_app
   resp = req.get_response(self.application)
 File 'build/bdist.macosx-10.3-i386/egg/webob/__init__.py', line 1307 in
 get_response
 File 'build/bdist.macosx-10.3-i386/egg/webob/__init__.py', line 1275 in
 call_application
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 
packages/ToscaWidgets-0.9.5dev_20081026-py2.5.egg/tw/core/resource_injector.py',
 line 67 in _injector
   resp = req.get_response(app)
 File 'build/bdist.macosx-10.3-i386/egg/webob/__init__.py', line 1307 in
 get_response
 File 'build/bdist.macosx-10.3-i386/egg/webob/__init__.py', line 1275 in
 call_application
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Beaker-1.1.2-py2.5.egg/beaker/middleware.py', line 81 in __call__
   return self.app(environ, start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Beaker-1.1.2-py2.5.egg/beaker/middleware.py', line 159 in
 __call__
   return self.wrap_app(environ, session_start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Routes-1.10.1-py2.5.egg/routes/middleware.py', line 118 in
 __call__
   response = self.app(environ, start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Pylons-0.9.7rc4-py2.5.egg/pylons/wsgiapp.py', line 117 in
 __call__
   response = self.dispatch(controller, environ, start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Pylons-0.9.7rc4-py2.5.egg/pylons/wsgiapp.py', line 316 in
 dispatch
   return controller(environ, start_response)
 File '/Users/percious/oss/tgdev/src/tgtest/tgtest/lib/base.py', line 36 in
 __call__
   return TGController.__call__(self, environ, start_response)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Pylons-0.9.7rc4-py2.5.egg/pylons/controllers/core.py', line 204
 in __call__
   response = self._dispatch_call()
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Pylons-0.9.7rc4-py2.5.egg/pylons/controllers/core.py', line 159
 in _dispatch_call
   response = self._inspect_call(func)
 File '/Users/percious/oss/tgdev/lib/python2.5/site-
 packages/Pylons-0.9.7rc4-py2.5.egg/pylons/controllers/core.py', line 95 in
 _inspect_call
   result = self._perform_call(func, args)
 File '/Users/percious/oss/tgdev/src/tg2/tg/controllers.py', line 508 in
 _perform_call
   self, controller, params, remainder=remainder)
 File '/Users/percious/oss/tgdev/src/tg2/tg/controllers.py', line 118 in
 _perform_call
   response = self._render_response(controller, output)
 File '/Users/percious/oss/tgdev/src/tg2/tg/controllers.py', line 222 in
 _render_response
   controller.decoration.lookup_template_engine(pylons.request)
 File '/Users/percious/oss/tgdev/src/tg2/tg/decorators.py', line 114 in
 lookup_template_engine
   engine, template, exclude_names = self.engines[content_type]
 KeyError: ''
 }}}


 On a side-note, I'd like to add the ability to replace
 "page?tg_format=xxx" with "page.xxx" This seems much cleaner and more
 restful.  What say ye?

-- 
Ticket URL: <http://trac.turbogears.org/ticket/2134>
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