[pylons-discuss] get_current_request() for debug output / logging?
Hi, the documentation is quite clear about the Don't do that!!! regarding usage of get_current_request(). But however I approach my problem, I end up with get_current_request being the best solution, so I thought I should ask for permission. ;-) Here is my scenario: I have some service object which is registered in my application registry and requested by my application code from there. The object is independent of Pyramid, can be used and tested in isolation, so everything's fine. Deep inside the service, I fire some events to allow logging of some debug information (generated http requests and so on). Now I would like to display this information in the debug toolbar, of course on a per request base. Obviously passing the request to my service object is not an option as it would break the decoupling. Passing some logging handler through the whole service API is not nice too. Actually that's what events are made for. So the event handler needs to know about the current request. Whatever solution I could think of, I would have to implement something like a thread local. And then I could also use the existing get_current_request. Does anybody see a better solution? cheers, Achim -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.
[pylons-discuss] How set X-Accel-Expires in add_view, add_static_view
Hello I want use cache nginx and cache browser. For managing cache nginx i use X-Accel-Expires. For managing cache browser i use Cache-Control. Cache-Control is simple, need set parameters http_cache in add_view and cache_max_age in add_static_view. But how set X-Accel-Expires in same level?(as a parameter in add_view) In my opinion such parameter does not exists or am I mistaken? if so, how to pass this parameter to tween? So I installed it there: config.add_view( cache_view, route_name='cache_view', renderer='test_cache_nginx:templates/index.jinja2', http_cache=10, * x_accel_expires=100*, ) #tween: def simple_tween_factory(handler, registry): def simple_tween(request): response = handler(request) #*x_accel_expires* = ... here i get parameter ... if not *x_accel_expires*: x_accel_expires = registry.settings.get('cache.x_accel_expires', 0) response.headers.add('X-Accel-Expires', x_accel_expires) return response return simple_tween -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.
[pylons-discuss] beginner: route_url param
hi all, how do I properly create a param with route_url ? when I do *return HTTPFound(location=request.route_url('user_recent', username=auth.username, page='1'), headers=headers) * /Users/Shared/webapp/lrd_env/lrd/lrd/views/articles.py(67)recent() - with ReqAuthorize(request): (Pdb) p request RequestWithUserAttribute at 0x106268c10 GET http://0.0.0.0:6543/admin/recent (Pdb) p request.GET GET([]) (Pdb) p request.params NestedMultiDict([]) (Pdb) p request.GET.get('page') None however, manually making the request in the browser yields expected results: safari: http://0.0.0.0:6543/admin/recent?page=1 p request (Pdb) RequestWithUserAttribute at 0x10629c7d0 GET http://0.0.0.0:6543/admin/recent?page=1 p request.params (Pdb) NestedMultiDict([(u'page', u'1')]) how am I forming route_url incorrectly? regards, Michael -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.
Re: [pylons-discuss] beginner: route_url param
On 20 Jul 2014, at 21:15, Michael taomaili...@gmail.com wrote: hi all, how do I properly create a param with route_url ? when I do return HTTPFound(location=request.route_url('user_recent', username=auth.username, page='1'), headers=headers) Use the _query parameter for route_url: url = request.route_url(‘user_recent’, _query={‘username’: auth.username, ‘page’: ‘1’}) HTTPFound(url, headers=headers) Wichert. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.
Re: [pylons-discuss] beginner: route_url param
This works, thanks. FYI I need the username to stay in the matchdict, so my final line looks like: return HTTPFound(location=request.route_url('user_recent', username=auth.username, _query={'page':'1'}), headers=headers) On Sunday, July 20, 2014 3:31:48 PM UTC-4, Wichert Akkerman wrote: On 20 Jul 2014, at 21:15, Michael taoma...@gmail.com javascript: wrote: hi all, how do I properly create a param with route_url ? when I do *return HTTPFound(location=request.route_url('user_recent', username=auth.username, page='1'), headers=headers) * Use the _query parameter for route_url: url = request.route_url(‘user_recent’, _query={‘username’: auth.username, ‘page’: ‘1’}) HTTPFound(url, headers=headers) Wichert. -- You received this message because you are subscribed to the Google Groups pylons-discuss group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.