On Sat, Nov 8, 2008 at 2:34 PM, Lukasz Szybalski <[EMAIL PROTECTED]> wrote:
>
> On Sat, Nov 8, 2008 at 3:55 PM, Mike Orr <[EMAIL PROTECTED]> wrote:
>>
>> On Sat, Nov 8, 2008 at 12:54 PM, Lukasz Szybalski <[EMAIL PROTECTED]> wrote:
>>>
>>> Hello,
>>>
>>> What needs to change to add public/ folder in front of anything that is 
>>> static.
>>>
>>> Currently it seems as I need to add
>>> Alias /css/ "/path.../"
>>> Alias /javascripts/ "/path.../"
>>> Alias /images/ "path.../"
>>>
>>> This gets complicated if I deploy 2 or more apps, then I suddenly need
>>> 3x usual number of aliases per each project.
>>>
>>> I would like to add
>>> Alias /public/ "path..tomyapp/public/"
>>>
>>> And everything in public could be referenced via
>>> localhost:8080/public/images/...
>>> localhost:8080/public/css/...

Maybe I didn't read this correctly.  If it's working now (meaning the
Alias handler overrides the wsgi handler), then you should be able to
change the alias path and it would still work.  In this case your
public directory is sim


>>> .....
>>> etc..
>>>
>>> Can pylons template change to so that all public/static files are
>>> served through localhost/public/ folder and not via each individual
>>> folder?
>>>
>>> like to get something like this by default:
>>> http://localhost:8080/public/images/logo.png
>>> http://localhost:8080/public/css/style.css
>>
>> You can do this by putting a public directory inside your public
>> directory.  If Pylons did this by default, people wouldn't be able to
>> put static files at the top level, including /robots.txt and
>> /favicon.ico which must be at the top level.
>>
> so i I place favicon.ico and robots.txt inside of public folder right
> now they will show up without any changes in:
>
> localhost/robots.txt
> localhost/favicon.ico  ??
>
>
> Another twist.....
> Is there a variable in pylons config files that says what the prefix
> name is? I would assume currently this variable would be set to:
> somevar="/" points to /myapp/public/
> and I would be able to change it to:
> somevar="/public/" points to /myapp/public/
> or
> somevar="/public-myapp/" points to /myapp/public/
>
> The reason I'm asking is that robots, favico, etc all are served by
> apache. The existing website takes care all of it, and has its own
> /images/ folder etc.... so now my modwsgi served app is only
> controlling localhost/myapp but still points to /images which causes a
> problem. I need to to point to something custom I have defined
> localhost/public-myapp/images/ . In the future I would add another
> separate app that would run under localhost/mysecondapp with its own
> public folder (localhost/public-mysecondapp which I would like to
> easily rename to public-mynewapp just by changing the config file
> without playing around with adding folders to public or creating
> custom functions to server static folders.

You have a pretty customized configuration.  In the normal case, with
the Pylons application at "/" and Apache not serving static files,
Pylons serves the static files via the static middleware at the bottom
of middleware.py:

    static_app = StaticURLParser(config['pylons.paths']['static_files'])
    app = Cascade([static_app, app])
    return app

Thus, /favicon.ico -> myapp/public/favicon.ico

The static app is tried first for all URLs.  If it returns with HTTP
404 Not Found, the dynamic application 'app' is tried instead.

So if you want static_app to assume a prefix (static/) on every URL...
you'd have to look at the source to see if it can with an argument,
and if not you'd have to write your own middleware based on it.

If use use Apache's Alias directive to serve the static files, the
wsgi application will never be invoked for them.  If it's working now
(i.e., if the Alias module overrides the wsgi module), then you should
be able to modify the path prefix to "Alias /public
MYPYLONSAPP/public".  However, this will cause the static files to
"move" from / to /public.  But the Pylons application doesn't know
this, so it would continue to serve any request for /images, etc.  If
you removed the Alias, the static files would no longer be found under
/public.  You would have to set up your routing and hyperlinks to use
the /public prefix, but then the application would break if the Alias
were ever removed, because the URLs would not exist if the application
served them.

Therefore if you want to use /public, you should make a public
subdirectory under public, *and* set up an Alias to it.  That way the
application will continue to function normally no matter whether the
Alias is enabled or not.  However, this won't work for /robots.txt and
/favicon.ico, which the browser assumes are directly under the root
URL.

You can move the entire Pylons application under a prefix such as
/myapp, and then the static files would also be underneath it
(/myapp/images -> myapp/public/images).  I think you have to set some
prefix option in the INI file if you do this; search the Pylons wiki
or list archive for an example.  Then the URLs produced by url_for
will have the correct prefix.  I don't quite understand what you're
trying to do in the last paragraph; but hopefull this will address
some of it.

-- 
Mike Orr <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-devel" 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-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to