Re: Calling a WSGI application from an action
Alberto Valverde wrote: I had a similar problem when mounting Trac inside a Pylons application as a controller. Apparently, at some stage environ['wsgi.input'] was consumed hence POST requests were seen blank by Trac once they reached it. I solved it using this piece of middleware [1] stacked closest to the server [2] to cache input in a regular temporary file so it can be 'rewound' before passing the request to Trac [3]. WebOb had some functions to do this, but after thinking about it I made it a bit easier. With WebOb trunk you can now do: req = Request(environ) req.make_body_seekable() And then at any time you can do req.body_file.seek(0) (or environ['wsgi.input'].seek(0)) before sending the request on to another application. req.copy() also does this, but if the body has been eaten by something like paste.request.parse_formvars (what all but the tip of Pylons uses, I think) then it won't really work, so you have to prep the environment this way. This looks very useful, I'll probably rewrite the code I posted sometime to make use of this feature and make it simpler. It's about the same thing as what you did, but you'd be better off using tempfile, tempfile has actually been one of my most recent discoveries in the standard library :) Just wanted to get rid of the annoying os.tempnam warning so I reinvented the wheel. Alberto --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Pylons Session help
Hi, I am working on a community website, using pylons. I needed to capture the user navigation by recording user interaction with the web site. I will store the urls with the query string (GET method, query param shall help me to understand what they are searching/looking) corresponding to the special session/cookie id. All I need is to setup a middleware in the pylons application stack. 1. When a request comes, middleware has to see the session id generated 2. If the session id present, it has to log the url with the session id/specific identifier to follow the requests 3. Either db/file, i can log the file Any idea how to achieve this? (Don't worry about privacy, integrity issues. This is purely technical, to analyze what user like the most in the site) Regards, Krishgy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Pylons and memory use
I was thinking about signing up with a web host that supports Pylons (among many other things) and one of the differences between the various plans is application memory for long-running processes. The plan I'd like to sign up for has 80MB. Does anyone know if this is enough for basic Pylons applications? My personal website works on 96MB together with postgres database and another python-based app. Should do, just pay attention to threads count, stack sizes and such. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Setting response body and status code when handling errors
On Jun 6, 11:24 pm, Mike Orr [EMAIL PROTECTED] wrote: On Fri, Jun 6, 2008 at 5:11 PM, mc [EMAIL PROTECTED] wrote: Hi, When an exception occurs in my application I want to ba able to set the response code and return a specific response body. I can set the response without a problem but Pylons seems to be overriding the response code and returns a 200 instead. Here's my code snippet: class MyController(BaseController) def index(self): result = {} try: # try-except result[result] = func(*args, **kwargs) except (KeyError, ValueError), e: response.status = 400 result[error] = str(e) except Exception, e: response.status = 500 result[error] = str(e) finally: return result I've read through the pylons docs on the wiki, but I can only find references to an abort() method which sets the response code but doesn't allow me to set the body. Any suggestions or pointers where I can look for more information I set up an access log in my base controller's .__call__ method, and for some reason the errors are showing up as 200. So something strange is happening to the status but I haven't figured out where. It could be related to your problem. The integer version of the status is in response.status_code, not response.status. Maybe you need to set it there. In the development version of Pylons it's in response.status_int due to the migration to WebOb. Setting response.status_code successfully changes the response code. Thanks for that. The problem now is that pylons error handling kicks in and clobbers the response body which I've already set. I think what I need to do is provide a custom error handler, but I'm not sure how to pass the exception information to the handler. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---