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/07/26 13:04:31 UTC
svn commit: r425700 - in /httpd/mod_python/trunk:
lib/python/mod_python/__init__.py lib/python/mod_python/importer.py
src/include/mpversion.h
Author: grahamd
Date: Wed Jul 26 04:04:29 2006
New Revision: 425700
URL: http://svn.apache.org/viewvc?rev=425700&view=rev
Log:
Added 'mp' qualifier into the names of the special mod_python variables put
into every module loaded by the new module importer. Changes are __info__
to __mp_info__, __clone__ to __mp_clone__ and __purge__ to __mp_purge__.
Code has been restructured so that module specific search path additions
can now be appended to module variable called __mp_path__ instead of
__info__.path. (MODPYTHON-143)
Modified:
httpd/mod_python/trunk/lib/python/mod_python/__init__.py
httpd/mod_python/trunk/lib/python/mod_python/importer.py
httpd/mod_python/trunk/src/include/mpversion.h
Modified: httpd/mod_python/trunk/lib/python/mod_python/__init__.py
URL: http://svn.apache.org/viewvc/httpd/mod_python/trunk/lib/python/mod_python/__init__.py?rev=425700&r1=425699&r2=425700&view=diff
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/__init__.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/__init__.py Wed Jul 26 04:04:29 2006
@@ -20,5 +20,5 @@
__all__ = ["apache", "cgihandler", "psp",
"publisher", "util", "python22"]
-version = "3.3.0-dev-20060709"
+version = "3.3.0-dev-20060726"
Modified: httpd/mod_python/trunk/lib/python/mod_python/importer.py
URL: http://svn.apache.org/viewvc/httpd/mod_python/trunk/lib/python/mod_python/importer.py?rev=425700&r1=425699&r2=425700&view=diff
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/importer.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/importer.py Wed Jul 26 04:04:29 2006
@@ -124,8 +124,12 @@
parent.f_globals['__file__'] == __file__):
parent = parent.f_back
- if parent and parent.f_globals.has_key('__info__'):
- return parent.f_globals['__info__']
+ if parent and parent.f_globals.has_key('__mp_info__'):
+ mp_info = parent.f_globals['__mp_info__']
+ mp_path = parent.f_globals['__mp_path__']
+ return (mp_info, mp_path)
+
+ return (None, None)
def _find_module(module_name, path):
@@ -160,15 +164,15 @@
# file = os.path.join(directory, module_name[2:])
elif module_name[:2] == './':
- context = _parent_context()
- if context is not None:
- directory = os.path.dirname(context.file)
+ (mp_info, mp_path) = _parent_context()
+ if mp_info is not None:
+ directory = os.path.dirname(mp_info.file)
file = os.path.join(directory, module_name[2:])
elif module_name[:3] == '../':
- context = _parent_context()
- if context is not None:
- directory = os.path.dirname(context.file)
+ (mp_info, mp_path) = _parent_context()
+ if mp_info is not None:
+ directory = os.path.dirname(mp_info.file)
file = os.path.join(directory, module_name)
if file is None:
@@ -186,13 +190,13 @@
if path is not None:
search_path.extend(path)
- context = _parent_context()
- if context is not None:
- local_directory = os.path.dirname(context.file)
+ (mp_info, mp_path) = _parent_context()
+ if mp_info is not None:
+ local_directory = os.path.dirname(mp_info.file)
search_path.append(local_directory)
- if context.path is not None:
- search_path.extend(context.path)
+ if mp_path is not None:
+ search_path.extend(mp_path)
options = apache.main_server.get_options()
if int(options.get('mod_python.importer.search_handler_root', '0')):
@@ -260,7 +264,6 @@
self.file = file
self.cache = cache
self.children = {}
- self.path = []
class _ModuleCache:
@@ -355,13 +358,13 @@
# details stashed into the parent module by the
# module importing system itself.
- context = _parent_context()
+ (mp_info, mp_path) = _parent_context()
# Check for an attempt by the module to import
# itself.
- if context:
- assert(file != context.file), "Import cycle in %s." % file
+ if mp_info:
+ assert(file != mp_info.file), "Import cycle in %s." % file
# Retrieve the per request modules cache entry.
@@ -389,8 +392,8 @@
if modules is not None:
if modules.has_key(label):
- if context:
- context.children[label] = time.time()
+ if mp_info:
+ mp_info.children[label] = time.time()
return modules[label]
# Now move on to trying to find the actual
@@ -440,7 +443,7 @@
# transferred.
if cache.module != None:
- if hasattr(cache.module, "__clone__"):
+ if hasattr(cache.module, "__mp_clone__"):
try:
# Migrate any existing state data from
# existing module instance to new module
@@ -450,14 +453,14 @@
msg = "Cloning module '%s'" % file
self._log_notice(msg)
- cache.module.__clone__(module)
+ cache.module.__mp_clone__(module)
except:
# Forcibly purging module from system.
- if hasattr(cache.module, "__purge__"):
+ if hasattr(cache.module, "__mp_purge__"):
try:
- cache.module.__purge__()
+ cache.module.__mp_purge__()
except:
pass
@@ -499,7 +502,7 @@
instance = _InstanceInfo(label, file, cache)
- module.__info__ = instance
+ module.__mp_info__ = instance
# Cache any additional module search path which
# should be used for this instance of the module
@@ -511,7 +514,7 @@
if path is None:
path = []
- instance.path = list(path)
+ module.__mp_path__ = list(path)
# Place a reference to the module within the
# request specific cache of imported modules.
@@ -553,8 +556,8 @@
atime = time.time()
- if context:
- context.children[label] = atime
+ if mp_info:
+ mp_info.children[label] = atime
# Update the cache.
@@ -568,7 +571,7 @@
# handler don't result in the module later being
# reloaded if they change.
- cache.children = dict(module.__info__.children)
+ cache.children = dict(module.__mp_info__.children)
# Increment the generation count of the global
# state of all modules. This is used in the
@@ -610,8 +613,8 @@
atime = time.time()
- if context:
- context.children[label] = atime
+ if mp_info:
+ mp_info.children[label] = atime
# Didn't need to reload the module so simply
# increment access counts and last access time.
@@ -842,9 +845,9 @@
# statement if parent module was imported using
# the same.
- context = _parent_context()
+ (mp_info, mp_path) = _parent_context()
- if context is None:
+ if mp_info is None:
return None
# Determine the list of directories that need to
@@ -856,11 +859,11 @@
search_path = []
- local_directory = os.path.dirname(context.file)
+ local_directory = os.path.dirname(mp_info.file)
search_path.append(local_directory)
- if context.path is not None:
- search_path.extend(context.path)
+ if mp_path is not None:
+ search_path.extend(mp_path)
options = apache.main_server.get_options()
if int(options.get('mod_python.importer.search_handler_root', '0')):
@@ -1372,11 +1375,11 @@
self.file = file
self.cache = cache
self.children = {}
- self.path = []
filter.req.ssi_globals["__file__"] = filter.req.filename
- filter.req.ssi_globals["__info__"] = _InstanceInfo(
+ filter.req.ssi_globals["__mp_info__"] = _InstanceInfo(
None, filter.req.filename, None)
+ filter.req.ssi_globals["__mp_path__"] = []
code = code.replace('\r\n', '\n').rstrip()
Modified: httpd/mod_python/trunk/src/include/mpversion.h
URL: http://svn.apache.org/viewvc/httpd/mod_python/trunk/src/include/mpversion.h?rev=425700&r1=425699&r2=425700&view=diff
==============================================================================
--- httpd/mod_python/trunk/src/include/mpversion.h (original)
+++ httpd/mod_python/trunk/src/include/mpversion.h Wed Jul 26 04:04:29 2006
@@ -1,5 +1,5 @@
#define MPV_MAJOR 3
#define MPV_MINOR 3
#define MPV_PATCH 0
-#define MPV_BUILD 20060709
-#define MPV_STRING "3.3.0-dev-20060709"
+#define MPV_BUILD 20060726
+#define MPV_STRING "3.3.0-dev-20060726"