Hy guys, Many thanks for your replies, a brief but strong lessons about python and shell.
Indeed, I went for a solution similar to what Malcolm suggested. I am using a file with env variables to be loaded. Thanks a lot guys again. The webserver is up and now we are just tunning the feel&look and tweaking css etc. Cheers, Alan On Thu, Feb 12, 2009 at 03:42, Graham Dumpleton <graham.dumple...@gmail.com>wrote: > > > > On Feb 12, 12:09 pm, Malcolm Tredinnick <malc...@pointy-stick.com> > wrote: > > On Tue, 2009-02-10 at 10:56 +0000, Alan wrote: > > > Hi list, > > > > > My problem is that: since when using apache + mod_wsgi I got a neutral > > > env for my server (e.g. PATH=/usr/bin:/bin) but in the end what I need > > > is all the envs that is in a particular $HOME/.bashrc file in order to > > > when server spawns a program (that may not be in the neutral PATH and > > > besides need some extra env parameters) it can run. > > > > > So what I was trying is to find a python module or code that would do > > > something like ". $HOME/basrc" inside my python code and before > > > executing my binary program in order to pass to it the particular > > > user's environment. > > > > The concept of $HOME or "user" doesn't really make sense for Apache. > > Well, it does, but the user running the Apache process will typically > > not have a home directory (or even be a login-enabled account). That's > > one clue that this probably isn't a neat solution. > > For Apache when using mod_python or embedded mode of mod_wsgi, very > true, $HOME can be various things, as can variables such as $USER, > $USERNAME and $LOGNAME. > > When Apache is started as part of operating system startup scripts at > boot time, then they would normally reflect the environment of the > 'root' user. > > If Apache is started using 'sudo' then what they are will depend upon > whether or not the -H option is supplied to 'sudo'. If -H option is > used, then they will again be that for 'root' user. If -H option is > not used, then they would normally correspond to that of the user who > ran 'sudo'. > > In other words, quite unpredictable and not something to be relied up. > > It is this reason why Python egg cache location will not always work > properly under Apache embedded mode, as it could be calculated to be > under 'root' account, in which case directory not creatable or > writable as Apache user, or it could be that of the user who ran > 'sudo'. In the latter everything may appear to work because they have > done stuff by hand to populate the cache, but when they reboot and it > decides to use root Python egg cache instead, everything breaks. > > For Apache when using mod_wsgi daemon mode, $HOME ill be correct as > mod_wsgi forces it to be so. This isn't done for embedded mode as it > is a shared environment with other Apache modules and bad practice to > make decision that can set it right. > > In mod_wsgi 2.X, $USER, $USERNAME or $LOGNAME will be still be wrong. > This has been fixed for mod_wsgi 3.0 though. Consequence of it being > wrong is that some Python packages can screw up because they believe > this value rather than determine what effective uid of process it. > Luckily only seen it causing a problem is logged error messages. For > example, if Trac has permissions problem it uses these variables to > say who it thinks the process runs as, which will not actually be true > and is quite confusing when looking at messages. > > Anyway, I would agree with Malcolm as far as not trying to rely on > user shell environment. Too easy for a slight change in user > environment to inadvertantly break your web application. > > Graham > > > > > -- Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK. >>http://www.bio.cam.ac.uk/~awd28<< --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---