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/...
>> .....
>> 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.
Let me know.
Lucas
> You can also use FileApp or DirectoryApp from paste.fileapp to serve a
> static file from any controller. I've only done it with FileApp.
>
> def attachment(self, orr_id, entry_id, filename, environ, start_response):
> """Display an attachment or thumbnail.
>
> Attachments are in the directory indicated by the "attachments_dir"
> config option. A particular attachment will be under the relative
> path: orr_id/entry_id/filename .
>
> Thumbnails are named "FILENAME_thumb200.jpg", and are always JPG.
>
> TODO: client-side caching.
> """
> orr_id = self._int_id(orr_id, "incident ID", 404)
> entry_id = self._int_id(entry_id, "entry ID", 404)
> self._REQUIRE_PERM("view_incident", orr_id=orr_id)
> attachments = config["attachments_dir"]
> path = Path(attachments, orr_id, entry_id, filename)
> app = FileApp(path)
> return app(environ, start_response)
>
> 'orr_id', 'entry_id', and 'filename' are routing variables from the
> URL path. 'environ' and 'start_response' are special arguments you
> can use in any controller action to return a WSGI application from an
> action. The first two lines verify the first two args are numeric and
> convert them to integers. The third line checks the user's
> permission. The fourth line reads the attachments root directory from
> the configuration. The ffifth line uses Path from the Unipath
> package, which is essentially doing the same thing as os.path.join.
> The sixth line creates a FileApp instance with the absolute path of
> the static file. The seventh line serves the file.
>
> With DirectoryApp, you can instantiate it with the root directory, but
> then I'm not sure how to pass the relative path when you call it. It
> reads the relative path from PATH_INFO, but I'm not sure how you get
> just {*url} without the part of the URL that pointed to the action
> without rewriting environ['PATH_INFO'] manually.
>
> --
> Mike Orr <[EMAIL PROTECTED]>
>
> >
>
--
Turbogears2 Manual
http://lucasmanual.com/mywiki/TurboGears2
Bazaar and Launchpad
http://lucasmanual.com/mywiki/bzr
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---