Help with creating view functions

2011-03-12 Thread AwaisMuzaffar
Hi Guys, I have the following code for the view: def pages_view(request): path = request.path.split('/')[1] dbsession = DBSession() page = dbsession.query(PagesTable).from_statement( 'SELECT * FROM pages WHERE path=:page_path').params(page_path=path).first() pages_dir = os

Re: Setting cookies in Pyramid for @action()s or HTTPFound redirects?

2011-03-12 Thread Jeff Dairiki
On Thu, Mar 10, 2011 at 01:07:32PM -0800, Seth wrote: > > Are those of us not returning "real" Response objects stuck with building > our cookie strings manually, or am I missing something here? I think you should be able to use a sacrificial WebOb Response object to construct the cookies for you

Re: Setting cookies in Pyramid for @action()s or HTTPFound redirects?

2011-03-12 Thread Michael Merickel
Going through the trouble of creating a webob response is much more complicated than simply adding a response_callback. def _set_cookie(request, response): response.set_cookie() request.add_response_callback(_set_cookie) Michael -- You received this message because you are subscribe

Re: Help with creating view functions

2011-03-12 Thread Michael Merickel
What is the exact error? I noticed you're using @view_config on the blog_view that isn't working, with only a renderer argument. This makes me think that you might believe that code will do the same as render_to_response(..) in your pages_view. In fact, @view_config is a different way of doing co

Re: Setting cookies in Pyramid for @action()s or HTTPFound redirects?

2011-03-12 Thread Jeff Dairiki
On Sat, Mar 12, 2011 at 01:55:21PM -0600, Michael Merickel wrote: > Going through the trouble of creating a webob response is much more > complicated than simply adding a response_callback. > > def _set_cookie(request, response): > response.set_cookie() > request.add_response_callback(

WebOb 1.0.2 + request.copy() + os.fork() + hang

2011-03-12 Thread Daniel Holth
I have been having trouble with request.copy() and ReloadWSGI with WebOb >= 1.0.2. In WebOb 1.0.2 and greater request.copy() hangs. static_url() uses request.copy() so my Pyramid application hangs as soon as it tries to serve some css. In WebOb 1.0.4 from pypi, it hangs at request.py:673 which

Re: CSRF protection and session factories

2011-03-12 Thread Mike Orr
On Wed, Mar 9, 2011 at 11:24 AM, Stephen Lacy wrote: > In my form handling view, I'm using code that looks like this: > >     if not request.session.csrf_valid(request.POST['csrft']): >         return HTTPInternalServerError() This is popular but I'd use HTTPBadRequest (400). It's a client error