On Mon, Apr 6, 2009 at 5:06 PM, Jason Reid <[email protected]> wrote:
>
> I have not "dived" into Pylons yet; but the question I am curious
> about is how I would use AuthKit's authentication (digest
> specifically) too protect static content (I dont mean images; I am
> server rather large; over 4GB files) and I need them secured.
You can move them out of the public directory and serve them in a
controller action; then you can apply the normal AuthKit controls to
it. For instance, I had to log a directory of static help files using
logging code I had already written for Pylons.
# routing.py
map.connect("help", "/help/{url:.*}", controller="main", action="help")
# MainController.py
def help(self, url, environ, start_response):
"""
``url`` is the rest of the request path.
``environ`` and ``start_response`` are special args in Pylons,
used to chain to another
WSGI application.
"""
# Using the Unipath package here, but you can use os.path instead.
url = Path(url or "index.htm")
page = url.stem # Base filename without directory or extension.
help_dir = Path(config["pylons.paths"]["help_files"]) # My
own config variable.
path = Path(help_dir, url)
if not path.exists():
abort(404)
if url.ext == ".htm" and not page.startswith("wh"):
self.sitestats.log_event("help", page) # My logging
code; log view of help section.
app = FileApp(path)
return app(environ, start_response)
--
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
-~----------~----~----~----~------~----~------~--~---