Graham Dumpleton wrote: > On Feb 24, 11:08 am, Michael Hipp <[EMAIL PROTECTED]> wrote: >> So how do I make those lines look like that instead of having a bunch of >> absolute paths stuck in there or lots of messy stuff with >> os.path.join(os.path.dirname(__file__)...) in it? > > Don't. You should never ever write a web application such that it will > only work if the current working directory is a specific directory, it > is just very bad practice to do so. > > This is because in hosting systems like Apache there is absolutely no > guarantee that the working directory will be something in particular > and you can't even change it to be a specific value and expect it to > work reliably. This is because in any sort of system where the process > is shared by other code you didn't write or which is outside of your > control, you can't prevent that other code also wanting to change the > working directory and subsequently screwing up your code. > > Python web frameworks or applications which have to one degree or > another made a choice to somehow rely on the current working directory > being a specific value are limiting the deployment choices for their > users by doing so. You are thus highly discouraged against doing it > and using __file__ as an anchor or a variable setting in main settings > configuration file is a better and more portable way of doing it.
Just to close the loop on this, Graham's explanation makes perfect sense. But why are these instructions even included in the book and in the documentation? ------ http://www.djangoproject.com/documentation/fastcgi/ http://www.djangobook.com/en/1.0/chapter20/ 'Running Django on a shared-hosting provider with Apache' "Create a file mysite.fcgi ..." # Switch to the directory of your project. (Optional.) # os.chdir("/home/user/myproject") ------ Shouldn't this be removed (or at least padded with some warnings) since it is arguably encouraging a (new?) user to do something that is poor practice or even dangerous. Thanks, Michael --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---