You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-commits@quetz.apache.org by nl...@apache.org on 2005/01/20 18:46:18 UTC
svn commit: r125798 - /httpd/mod_python/trunk/src/include/mod_python.h /httpd/mod_python/trunk/src/mod_python.c /httpd/mod_python/trunk/test/htdocs/subdir/tests.py /httpd/mod_python/trunk/test/test.py
Author: nlehuen
Date: Thu Jan 20 09:46:15 2005
New Revision: 125798
URL: http://svn.apache.org/viewcvs?view=rev&rev=125798
Log:
A candidate fix for both [#MODPYTHON-4] and [#MODPYTHON-6].
- removed the SLASH and SLASH_S defines, and replaced it by '/' and "/" respectively everywhere they were used. Apache lives in a Posix world, and even Win32 paths are translated before being handled by mod_python.
- in PythonInterpPerDirectory mode, we should not add an extra '/' when a directory is requested. This way, /subdir/ and /subdir/foo.py should be handled in the same interpreter.
- Enhanced the PythonInterpPerDirective tests and added a PythonInterpPerDirectory test.
Removed:
httpd/mod_python/trunk/test/htdocs/subdir/tests.py
Modified:
httpd/mod_python/trunk/src/include/mod_python.h
httpd/mod_python/trunk/src/mod_python.c
httpd/mod_python/trunk/test/test.py
Modified: httpd/mod_python/trunk/src/include/mod_python.h
Url: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/src/include/mod_python.h?view=diff&rev=125798&p1=httpd/mod_python/trunk/src/include/mod_python.h&r1=125797&p2=httpd/mod_python/trunk/src/include/mod_python.h&r2=125798
==============================================================================
--- httpd/mod_python/trunk/src/include/mod_python.h (original)
+++ httpd/mod_python/trunk/src/include/mod_python.h Thu Jan 20 09:46:15 2005
@@ -91,13 +91,7 @@
#define MODULENAME "mod_python.apache"
#define INITFUNC "init"
#define MAIN_INTERPRETER "main_interpreter"
-#ifdef WIN32
-#define SLASH '\\'
-#define SLASH_S "\\"
-#else
-#define SLASH '/'
-#define SLASH_S "/"
-#endif
+
/* used in python_directive_handler */
#define SILENT 0
#define NOTSILENT 1
Modified: httpd/mod_python/trunk/src/mod_python.c
Url: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/src/mod_python.c?view=diff&rev=125798&p1=httpd/mod_python/trunk/src/mod_python.c&r1=125797&p2=httpd/mod_python/trunk/src/mod_python.c&r2=125798
==============================================================================
--- httpd/mod_python/trunk/src/mod_python.c (original)
+++ httpd/mod_python/trunk/src/mod_python.c Thu Jan 20 09:46:15 2005
@@ -568,8 +568,8 @@
py_config *conf = python_create_config(p);
/* make sure directory ends with a slash */
- if (dir && (dir[strlen(dir) - 1] != SLASH))
- conf->config_dir = apr_pstrcat(p, dir, SLASH_S, NULL);
+ if (dir && (dir[strlen(dir) - 1] != '/'))
+ conf->config_dir = apr_pstrcat(p, dir, "/", NULL);
else
conf->config_dir = apr_pstrdup(p, dir);
@@ -816,7 +816,7 @@
}
else {
/* if ((req->path_info) && */
-/* (req->path_info[strlen(req->path_info) - 1] == SLASH)) */
+/* (req->path_info[strlen(req->path_info) - 1] == '/')) */
/* { */
/* int i; */
/* i = strlen(req->path_info); */
@@ -831,7 +831,7 @@
/* if (!request_obj) return NULL; */
/* /\* put the slash back in *\/ */
-/* req->path_info[i - 1] = SLASH; */
+/* req->path_info[i - 1] = '/'; */
/* req->path_info[i] = 0; */
/* /\* and also make PATH_INFO == req->subprocess_env *\/ */
@@ -897,10 +897,21 @@
if ((s = apr_table_get(conf->directives, "PythonInterpPerDirectory"))) {
/* base interpreter on directory where the file is found */
- if (req && ap_is_directory(req->pool, req->filename))
- return ap_make_dirstr_parent(req->pool,
- apr_pstrcat(req->pool, req->filename,
- SLASH_S, NULL ));
+ if (req && ap_is_directory(req->pool, req->filename)) {
+ /** XXX I suppose that if req->filename is a directory, there already
+ is a trailing slash in req->filename. This is due to the fact
+ that Apache redirect any request from /directory to /directory/.
+ That's why the tests below are commented out, they should be useless.
+ **/
+ /* if (req->filename[strlen(req->filename)-1]=='/') { */
+ return ap_make_dirstr_parent(req->pool, req->filename);
+ /* }
+ else {
+ return ap_make_dirstr_parent(req->pool,
+ apr_pstrcat(req->pool, req->filename,
+ "/", NULL ));
+ } */
+ }
else {
if (req && req->filename)
return ap_make_dirstr_parent(req->pool, req->filename);
Deleted: /httpd/mod_python/trunk/test/htdocs/subdir/tests.py
Url: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/test/htdocs/subdir/tests.py?view=auto&rev=125797
==============================================================================
Modified: httpd/mod_python/trunk/test/test.py
Url: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/test/test.py?view=diff&rev=125798&p1=httpd/mod_python/trunk/test/test.py&r1=125797&p2=httpd/mod_python/trunk/test/test.py&r2=125798
==============================================================================
--- httpd/mod_python/trunk/test/test.py (original)
+++ httpd/mod_python/trunk/test/test.py Thu Jan 20 09:46:15 2005
@@ -732,13 +732,52 @@
print "\n * Testing interpreter per directive"
+ interpreter_name = DOCUMENT_ROOT.replace('\\','/')+'/'
+
rsp = self.vhost_get("test_interpreter_per_directive")
+ if (rsp != interpreter_name):
+ self.fail(`rsp`)
+
+ rsp = self.vhost_get("test_interpreter_per_directive",'/subdir/foo.py')
+ if (rsp != interpreter_name):
+ self.fail(`rsp`)
+
+ rsp = self.vhost_get("test_interpreter_per_directive",'/subdir/')
+ if (rsp != interpreter_name):
+ self.fail(`rsp`)
+
+ def test_interpreter_per_directory_conf(self):
+
+ c = VirtualHost("*",
+ ServerName("test_interpreter_per_directory"),
+ DocumentRoot(DOCUMENT_ROOT),
+ Directory(DOCUMENT_ROOT,
+ PythonInterpPerDirectory('On'),
+ SetHandler("mod_python"),
+ PythonHandler("tests::interpreter"),
+ PythonDebug("On")),
+ )
+
+ return str(c)
+
+ def test_interpreter_per_directory(self):
+
+ print "\n * Testing interpreter per directory"
interpreter_name = DOCUMENT_ROOT.replace('\\','/')+'/'
-
+
+ rsp = self.vhost_get("test_interpreter_per_directory")
if (rsp != interpreter_name):
self.fail(`rsp`)
+ rsp = self.vhost_get("test_interpreter_per_directory",'/subdir/foo.py')
+ if (rsp != interpreter_name+'subdir/'):
+ self.fail(`rsp`)
+
+ rsp = self.vhost_get("test_interpreter_per_directory",'/subdir/')
+ if (rsp != interpreter_name+'subdir/'):
+ self.fail(`rsp`)
+
def test_util_fieldstorage_conf(self):
c = VirtualHost("*",
@@ -1155,9 +1194,10 @@
perRequestSuite.addTest(PerRequestTestCase("test_Cookie_Cookie"))
perRequestSuite.addTest(PerRequestTestCase("test_Cookie_MarshalCookie"))
perRequestSuite.addTest(PerRequestTestCase("test_Session_Session"))
+ perRequestSuite.addTest(PerRequestTestCase("test_interpreter_per_directive"))
+ perRequestSuite.addTest(PerRequestTestCase("test_interpreter_per_directory"))
# this must be last so its error_log is not overwritten
perRequestSuite.addTest(PerRequestTestCase("test_internal"))
- perRequestSuite.addTest(PerRequestTestCase("test_interpreter_per_directive"))
self.makeConfig(PerRequestTestCase.appendConfig)
self.startHttpd()