Cool, would this also work behind a proxy server? The static path being on the proxy?
On Jun 27, 8:57 am, Max Ischenko <[EMAIL PROTECTED]> wrote: > On Jun 11, 1:48 pm, "Max Ischenko" <[EMAIL PROTECTED]> wrote: > > > Hello, > > > Default Pylons setup (middleware.py) configures StaticURLParser to handle > > APP/public/ which contains static dir. I wanted a slightly different setup > > and moved APP/public/static to static/ dir. Now I can't get it to work with > > StaticURLParser: it wants a serve everything under specific dir and in my > > case it means whole source tree. > > > How can I make sure Pylons serves static files from static/ dir under URL > > path /static? > > Here is the solution I used; may be someone find it helpful too. > > class MyStaticHandler(object): > def __init__(self, static_dir): > self.app = StaticURLParser(static_dir) > > def __call__(self, environ, start_response): > path_info = environ.get('PATH_INFO') or '' > if path_info.startswith('/static/'): > # trim /static/ prefix so that StaticURLParser > # can actually locate the file > environ['PATH_INFO'] = path_info[len('/static/'):] > return self.app(environ, start_response) > else: > return self.app.not_found(environ, start_response) > > This WSGI bit is used in place of normal static_app; all it does is > modify PATH_INFO so that StaticURLParser can work correctly. > > Max. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---