On Fri, Jul 23, 2010 at 4:52 AM, Jens Hoffrichter
<[email protected]> wrote:
> On 22 July 2010 20:01, Mike Orr <[email protected]> wrote:
>>>> > I think you want something like this.
>>>> >
>>>> > from paste.fileapp import FileApp
>>>> >
>>>> > #.... in controller ....
>>>> >         #...in some action, get the path to serve
>>>> >         wsgi_app = FileApp(path)
>>>> >         return wsgi_app(request.environ, self.start_response)
>>>>
>>>> Yes, use paste.fileapp.  You can just return the wsgi_app object
>>>> directly, and Pylons will call it for you.
>>>
>>> Don't you also need to wrap it in pylons.controllers.util.forward?
>>>
>>> http://pylonshq.com/docs/en/0.9.7/modules/controllers_util/#pylons.controllers.util.forward
>>>
>>> (I haven't tried simply returning FileApp() myself, but I have memories
>>> of someone on IRC who tried and got scant success.)
>>
>>    def bnb(self):
>>        app = FileApp("/home/mso/data/images/bnb.gif")
>>        return app
>>
>> TypeError: 'FileApp' object is not iterable
>>
>> I guess you can't. I must be remembering wrong.
>>
>> In any case, forward() is a wrapper that extracts the environ and
>> start_response for you and calls the app.
> The original proposal works like a charm in Pylons 0.9.6.2 - maybe
> there were some incompatible changes in a later version, which make it
> impossible to still use it that way?

The original proposal:

    return app(request.envrion, self.start_response)

still works. It's returning the application instance itself that
doesn't work. Maybe it did in an earlier version, or maybe I'm
misremembering something similar from another context.

BTW, you can also get 'environ' and 'start_response' as magic action arguments:

    def my_action(self, environ, start_response)

That's how I've been doing it, but I'm going to switch to forward().

-- 
Mike Orr <[email protected]>

-- 
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.

Reply via email to