On Sun, Sep 23, 2012 at 9:43 AM, Raj Nathani <raj_...@hotmail.com> wrote:
> 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
> starter
> scaffold has a package in which there are two folders - templates and
> static.
>
> 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
> help?
> 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>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to