Alex Marandon wrote: > Hello, > > I'm trying to integrate FCKeditor's file management and upload > features into a Pylons app. FCKeditor ships with a WSGI application to > handle the server side of these features.
That's cool, that's one of the first cases I've heard of a Javascript product shipping something in WSGI (usually it's just PHP). > I tried to run that > application under mod_wsgi and it works fine. Now I'd like to > integrate that within my Pylons app to take advantage of my > authentication mechanism, so that only registered users can upload > files. > > I'm trying to apply the recipe from > http://wiki.pylonshq.com/display/pylonsdocs/Web+Server+Gateway+Interface+Support#running-a-wsgi-application-from-within-a-controller > > Unfortunately it works only for the file management features, not for > the upload. After digging into FCKeditor's Python code I figured out > that the WSGI app doesn't get all the data it needs from from the WSGI > environment. I dumped the WSGI environment when running the app under > mod_wsgi directly and within Pylons and there happen to be a lot of > differences between the two. I'm wondering if there would be a way to > get access to the "original" WSGI environment, before it gets modified > by Pylons, so that it would be compatible with what a "regular" WSGI > application expect. WebOb makes this easier, with: resp = req.get_response(fckeditor_wsgi) If you aren't using a very new version of Pylons, you can make a webob request with webob.Request(request.environ) However, there is a problem that the POST body can be eaten up. WebOb specifically tries to reconstruct it, but not for file uploads (simply because I didn't get around to it, because it's harder to construct than a simple POST form). And maybe what you are encountering is this same issue. This recipe roughly describes what a file upload looks like: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306 You need code that takes req.POST and turns it into the serialized body, so that the WSGI app you are calling can reconstruct that body. I'd be happy for webob to be able to do this, if you are inclined to add it there -- the code is in webob.FakeCGIBody._get_body(), and the instance would have to be aware of the Content-Type of the upload, and if it's multipart/form-data then it would have to reconstruct the body differently, in line with what that recipe does. > Another minor issue I've got is that the HTTP Content-Type header > (text/xml in this case) is not sent properly when calling the WSGI app > from Pylons. That one is not very critical as I can set it with the > controller action which calls the WSGI app. I can't think of anything that would change that header; maybe it wasn't set properly on the request to start with? -- Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
