On Sep 16, 2005, at 3:25 PM, mario ruggier wrote:
Hi,
imagine several packages for the same application, installed
simultaneously on the same machine. These can be for example a recent
stable/demo version, and a bleeding edge dev version. I want to be
able to run them concurrently, but independently. To run with either
simple_server or scgi_server, I am executing the respective python
scripts as new processes, that implies that if I adjust os.path in the
calling process, I cannot pass that env info to the child process. Or
can I?
Looking at the code, I wonder whether it is (a) a good idea and (b)
possible to be able to pass on to whichever server a parameter to add
a specific dir to its os.path. I was imagining that either the factory
param takes the form of
- str : as it is currently...
- (str, str) : a 2-tuple of str, where the frist str will be
interpreted as a dir to add to os.path
Then, the quixote.util.import_object(name) is similarly modified, e.g.
to:
quixote.util.import_object(name, add_to_path=None):
if add_to_path is not None:
if add_to_path not in os.path:
sys.path.insert(0, add_to_path)
...
rest of function as as currently
This does not work as advertised, because it is not possible to pass a
tuple as a shell script parameter ;-(
Another way would be to add an "add_to_path" option to the various
server scripts, that will then be handled separately (and before) from
the import_object() call.
This does work. For example, all that is necessary is to wrap the call
to parse_args() (in the main() or equivalent of each server script e.g.
in quixote.server.scgi_server.main) with the following:
main():
....
parser.add_option(
'--prepend-import-path', dest="path", default=None,
help="Prepend path to python's import path")
(options, args) = parser.parse_args()
if options.path is not None:
import sys
sys.path.insert(0, options.path)
Then, when run() is called, import_object(factory) works as expected.
Does this sound reasonable, or is there a much simple way to do this?
I guess another way to do this is to launch by importing and calling
the respective server run(). But this has other non-desirable
side-effects, such as running under the (ps) name of the calling
utility script... and that I have things set-up to not run this way ;-(
mario
_______________________________________________
Quixote-users mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/quixote-users