On Fri, 2011-03-04 at 09:45 -0800, Jonathan Vanasco wrote:
> i'm trying to port an old perl project ( which was essentially
> middleware for the mod_perl environment ) to Pyramid/WSGI
> 
> The basic premise is that it:
> - migrates the x-fowraded-for header into remote-addr
> - but only from accepted servers by ip
> - but only from accepted servers with a lan secret
> 
> this way, your app functions as normal with no necessary logic needed,
> and you can toss it behind as many loadbalancers or proxies you need.
> 
> the 2 issues i've been running into are:
> 
> 1.  how should I configure this?  Should I have the middleware import
> config stuff ( if so, is there a reference ?)  or should that all
> happen in the pyramid app when I layer in the middleware ?

Middleware should not depend on Pyramid.  This middleware sounds pretty
trivial, and likely should not.

If it must (for whatever reason, perhaps you believe that you must get
"accepted servers" from a database connection that only Pyramid knows
about), you'd be better off implementing this as a NewRequest or
ContextFound event subscriber rather than as middleware and have the
event subscriber raise an exception if the preconditions are not met.

> 2.  is it even possible to raise a 403 in middleware and prevent the
> app from running ?

With middleware you control the horizontal and vertical.  You can choose
to invoke the application you're wrapping or not as you like.

- C



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