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 gr...@apache.org on 2006/04/23 12:05:45 UTC

svn commit: r396248 - /httpd/mod_python/trunk/lib/python/mod_python/importer.py

Author: grahamd
Date: Sun Apr 23 03:05:43 2006
New Revision: 396248

URL: http://svn.apache.org/viewcvs?rev=396248&view=rev
Log:
Remove the "~/" shortcut for referencing modules by path stored in
directory specified by the Python*Handler directive, when using
apache.import_module() and when specifying the handler as option to the
directive. In the case of the option to the directive itself, the "./" and
"../" shorcuts can be used instead. (MODPYTHON-143)

Modified:
    httpd/mod_python/trunk/lib/python/mod_python/importer.py

Modified: httpd/mod_python/trunk/lib/python/mod_python/importer.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/lib/python/mod_python/importer.py?rev=396248&r1=396247&r2=396248&view=diff
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/importer.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/importer.py Sun Apr 23 03:05:43 2006
@@ -154,10 +154,10 @@
     if os.path.isabs(module_name):
         file = module_name
 
-    elif module_name[:2] == '~/':
-        directory = get_directory()
-        if directory is not None:
-            file = os.path.join(directory, module_name[2:])
+    #elif module_name[:2] == '~/':
+    #    directory = get_directory()
+    #    if directory is not None:
+    #        file = os.path.join(directory, module_name[2:])
 
     elif module_name[:2] == './':
         context = _parent_context()
@@ -1183,12 +1183,23 @@
             # current request so that it will be
             # available from within 'import_module()'.
 
+            directory = filter.dir
+            handler = filter.handler
+
+            if handler[:2] == './':
+                if directory is not None:
+                    handler = os.path.join(directory, handler[2:])
+
+            elif handler[:3] == '../':
+                if directory is not None:
+                    handler = os.path.join(directory, handler)
+
             config = filter.req.get_config()
-            cache = _setup_config_cache(config, filter.dir)
+            cache = _setup_config_cache(config, directory)
 
             (aborted, result) = _process_target(config=config,
-                    req=filter.req, directory=filter.dir,
-                    handler=filter.handler, default=default_handler,
+                    req=filter.req, directory=directory,
+                    handler=handler, default=default_handler,
                     arg=filter, silent=0)
 
             if not filter.closed:
@@ -1281,11 +1292,20 @@
                 # available from within 'import_module()'.
 
                 directory = hlist.directory
+                handler = hlist.handler
+
+                if handler[:2] == './':
+                    if directory is not None:
+                        handler = os.path.join(directory, handler[2:])
+
+                elif handler[:3] == '../':
+                    if directory is not None:
+                        handler = os.path.join(directory, handler)
 
                 cache = _setup_config_cache(config, directory)
 
                 (aborted, result) = _process_target(config=config, req=req,
-                        directory=directory, handler=hlist.handler,
+                        directory=directory, handler=handler,
                         default=default_handler, arg=req, silent=hlist.silent)
 
             finally: