[mod_python] sys.argv does not work when accessed with mod_python]

Sigurdur Einarsson doktornull at lhi.is
Fri Sep 16 11:30:02 EDT 2005

-------- Original Message --------
From: 	- Fri Sep 16 13:55:29 2005
X-Mozilla-Status: 	0001
X-Mozilla-Status2: 	00800000
Message-ID: 	<432ACECF.5020709 at lhi.is>
Date: 	Fri, 16 Sep 2005 13:55:27 +0000
From: 	Sigurdur Einarsson <doktornull at lhi.is>
Reply-To: 	doktornull at lhi.is
Organization: 	lhi.is
User-Agent: 	Mozilla Thunderbird 1.0.6 (X11/20050912)
X-Accept-Language: 	en-us, en
MIME-Version: 	1.0
To: 	Graham Dumpleton <grahamd at dscpl.com.au>
Subject: 	Re: [mod_python] sys.argv does not work when accessed with
References: 	<4322D765.3090808 at lhi.is>
<53cfa274179f6ab9185aefb318f9f45c at dscpl.com.au>
In-Reply-To: 	<53cfa274179f6ab9185aefb318f9f45c at dscpl.com.au>
Content-Type: 	text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 	7bit

Hi Graham,
I am using forms, and they are being loaded and executed within in
different paths.  In php the use $_SERVER['PHP_SELF'].
Thank you so much for your help.


Graham Dumpleton wrote:

> On 10/09/2005, at 10:53 PM, Sigurdur Einarsson wrote:
>> Hello list,
>> It seems like I'm unable to use sys.argv[0] with mod_python, it
>> functions in the shell.  Is there something in mod_python that will do
>> the same thing or is there a way to allow mod_python to access the
>> function, assuming this is a security issue?
> What exactly are you expecting to be obtaining from sys.argv[0]?
> In a Python script run from the command line sys.argv[0] will yield the
> pathname of the actual script which was run. Under mod_python, even if
> sys.argv were able to somehow be set properly, the process corresponds
> to an invocation of Apache "httpd" application.
> Not knowing exactly what you are after, I'll give a few suggestions as
> to what is available.
> 1. In any Python module file, you can access the global "__file__". This
> will give the pathname to the file corresponding to that module. The
> last component of the pathname may be useful in identifying the
> resource. Ie., 'os.path.split(__file__)[1]'.
> 2. For a particular request, you can access "req.filename". This is the
> physical resource as identified by Apache as being the target of a
> request. Again, the last component of the pathname maybe useful.
> 3. Especially if you are using mod_python.publisher, req.path_info may
> be useful. The value of this is what is used to identify the actual
> function which is being executed.
> Is what you are after the resource name as identified by a URI, or the
> name of the particular function which was mapped to and called by
> mod_python or some extension for mod_python, such as will be the case
> with mod_python.publisher?
> Graham

More information about the Mod_python mailing list