On Sun, Sep 23, 2012 at 9:43 AM, Raj Nathani <raj_...
> Hey I'm kind of new to Pyramid and web frameworks in general. One of the
> things I've learnt so far is that every Pyramid project created with a
> scaffold has a package in which there are two folders - templates and
> Is it necessary to keep the structure this way? Would the whole thing work
> fine if the folders were renamed/in-existent (with template and static files
> out one level higher in the projects root folder instead)? I'm pretty sure
> it isn't.
The main issue is specifying the paths. "myapp:templates/...", or
"templates/...", depends on the directory being inside a Python
package. MyApp/myapp is an importable Python package. MyApp isn't.
You'd have to create a relative path using __file__, or specify an
absolute path, and I'm not sure if these are compatible with
add_static_view() or renderer= anyway.
> But that
> brings me to my next question, which is about the 'static' folder, I've
> seen calls from python scripts within the project which declare in some of
> way that 'static' content is served from 'static' folder. How does this
> Does Pyramid have a different and faster way of serving files which it
> knows are static?
No, it's a convenience for the developer. The scaffolds predefine a
view for URL "/static" pointing to "myapp:static". That provides a
place for all static files to go, without the developer having to
define a view and a directory. You can of course have multiple static
directories for different purposes.
The fastest way to serve static files in production, is to arrange for
the main webserver (Apache) to serve the static directory directly
rather than passing those requests to the application.
Mike Orr <sluggos...@gmail.com>