On Sat, Dec 26, 2009 at 4:21 PM, edgarsmolow <[email protected]> wrote:
> Related question:
> Suppose I have a file in a directory *not* under public, and in fact
> not directly under the Pylons root directory. Let's' say it's defined
> in the project ini file as:
> myproject.special_dir = %(here)s/special
> I can then access the directory throughout my project as
> g.special_dir. Here's my question:
> Suppose that directory contains video files (movies). What would the
> value attribute be set to for filename "myfirstmovie.mov"?
>
> <object width="300" height="200">
> <param name="movie" value="some-value-goes-here"></param>
> <param name="allowFullScreen" value="true"></param>
> <param name="allowscriptaccess" value="always"></param>
> <embed src=value="some-value-goes-here" type="application/x-
> shockwave-flash" allowscriptaccess="always" allowfullscreen="true"
> width="300" height="200"></embed>
You'd have to serve it in a controller action using
paste.fileapp.FileApp or DirectoryApp.
(There's another fileapp-like thing, and I can never remember the
differences between it and fileapp.) You'd have to create a route to
the action, and the URL would be whatever the route specifies. So
something like this:
map.connect("/urlprefix/{path:.*}", controller="mycontroller",
action="myaction")
def myaction(self, path, environ, start_response):
realpath = os.path.join(config["myproject.special_dir"], path)
app = FileApp(realpath)
return app(environ, start_response)
This would match any path including those which contain a slash. (You
should probably prohibit ".." for security, by checking for it and
aborting 404.) It then creates a WSGI application and calls it. You
may be able to use pylons.controllers.util.forward(); I'm not sure --
it has very specific requirements.
I suppose DirectoryApp is not as useful with Pylons, but maybe you can
figure out a way to use it.
--
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.