Re: [Repoze-dev] routing exception when run as wsgi application

2010-06-02 Thread Yuan HOng
 You can use pdb with mod_wsgi. Read:

 http://code.google.com/p/modwsgi/wiki/DebuggingTechniques

 You also find in there how to use EvalException from Paste to do in
 browser debugging.

 Graham

Thanks Graham for the tip. Now I found out what's wrong.

When the application is run under Apache, the request header doesn't
contain the 'Content-Type' header while under Paste, it is filled with
an empty string when absent. So under Apache, the code snippet in
configuration.py:

 def header_predicate(context, request):
if header_val is None:
return header_name in request.headers
val = request.headers.get(header_name)
return header_val.match(val) is not None

will throw an except since val is None.

Changing the line to:

val = request.headers.get(header_name, '')

fixes the problem.

--
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] routing exception when run as wsgi application

2010-05-27 Thread Chris McDonough
Hi,

That doesn't appear to be the full traceback.  The most important bit is
at the end.  Could we see that part?

- C


On Wed, 2010-05-26 at 10:02 +0800, Yuan HOng wrote:
 Hi,
 
 I have an application with the following routing configuration:
 
 route
 path=wishlist
 name=wishlistjson
 header=Content-Type:application/json;*
 xhr=true
 factory=.order.wishlistview.wishlist_factory
 view=.order.wishlistview.WishlistJSONView
 view_renderer=json /
 
 route
 path=wishlist
 name=wishlist
 xhr=true
 factory=.order.wishlistview.wishlist_factory
 view=.order.wishlistview.WishlistView
 view_renderer=order/wishlist.pt /
 
 The same url path is used for both JSON request and normal ajax html
 load. The configuration works fine when run with paster. However when
 run with mod_wsgi + apache2, I got the follow exception in the Apache
 error log:
 
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1] mod_wsgi
 (pid=1818): Exception occurred processing WSGI script
 '/home/hong/hm.web/trunk/hm.web.wsgi'.
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1] Traceback (most
 recent call last):
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1]   File
 /home/hong/hm.web/lib/python2.6/site-packages/Beaker-1.5.3-py2.6.egg/beaker/middleware.py,
  lin
 e 152, in __call__
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1] return
 self.wrap_app(environ, session_start_response)
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1]   File
 /home/hong/hm.web/lib/python2.6/site-packages/repoze.tm2-1.0a5-py2.6.egg/repoze/tm/__init__.py
 , line 23, in __call__
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1] result =
 self.application(environ, save_status_and_headers)
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1]   File
 /home/hong/hm.web/lib/python2.6/site-packages/repoze.bfg-1.3a3-py2.6.egg/repoze/bfg/router.py,
  line 76, in __call__
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1] info =
 self.routes_mapper(request)
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1]   File
 /home/hong/hm.web/lib/python2.6/site-packages/repoze.bfg-1.3a3-py2.6.egg/repoze/bfg/urldispatch
 .py, line 54, in __call__
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1] if preds and
 not all((p(None, request) for p in preds)):
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1]   File
 /home/hong/hm.web/lib/python2.6/site-packages/repoze.bfg-1.3a3-py2.6.egg/repoze/bfg/urldispatch
 .py, line 54, in genexpr
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1] if preds and
 not all((p(None, request) for p in preds)):
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1]   File
 /home/hong/hm.web/lib/python2.6/site-packages/repoze.bfg-1.3a3-py2.6.egg/repoze/bfg/configurati
 on.py, line 1680, in header_predicate
 [Wed May 26 09:12:59 2010] [error] [client 127.0.1.1] return
 header_val.match(val) is not None
 
 Since it is not possible to use pdb with mod_wsgi, I don't know how to
 further trace and fix the situation.
 
 -- 
 Hong Yuan
 
 大管家网上建材超市
 装修装潢建材一站式购物
 http://www.homemaster.cn
 ___
 Repoze-dev mailing list
 Repoze-dev@lists.repoze.org
 http://lists.repoze.org/listinfo/repoze-dev


___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev