Re: public folder
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. I really don't consider this customized configuration. Its a standard deploy action when you are extending functionality of some website using pylons. I can never assume that pylons app will run under /. 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. 1. How could the middleware be changed to control the prefix. Currently is set to / aka. localhost/images I would like to add a variable in there that would allow me to change that prefix to /public-myapp aka.localhost/public-myapp/images? 2. Assuming I can do 1 (add a variable that controls static_files prefix), how can I move it and add it to development.ini so it can be set on individual basis? When this variable is set the pylons app would know internally to look for static files in localhost:port/public-myapp/images if run with paster serve as well. 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. no go then, unless I tell pylons app about the change. You are correct on the problems with URL. If I create alias images-myapp then my pylons app need to know that it has changed and I think the only solution
Re: public folder
On Sun, Nov 9, 2008 at 1:40 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. I really don't consider this customized configuration. Its a standard deploy action when you are extending functionality of some website using pylons. I can never assume that pylons app will run under /. 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 Not sure if this can help you guys but in Turbogears 1 there were settings in app.cfg that stated the following: [/static] static_filter.on = True static_filter.dir = %(top_level_dir)s/static [/favicon.ico] static_filter.on = True static_filter.file = %(top_level_dir)s/static/images/favicon.ico Is anything like this available via pylons 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. I've added the prefix but the image location is still pointing to /images and not /myapp/images??? filter-with = proxy-prefix [filter:proxy-prefix] use = egg:PasteDeploy#prefix prefix = /myapp I guess this is a no go as well. Lucas --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en -~--~~~~--~~--~--~---
Re: public folder
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. 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] --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en -~--~~~~--~~--~--~---
Re: public folder
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 pylons-devel@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: public folder
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