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/05/24 11:59:46 UTC

svn commit: r178147 - /httpd/mod_python/trunk/lib/python/mod_python/cache.py

Author: nlehuen
Date: Tue May 24 02:59:45 2005
New Revision: 178147

URL: http://svn.apache.org/viewcvs?rev=178147&view=rev
Log:
The module names cannot be "strange names", i.e. contain path separators or dots. I guess this is due to the relative import mechanisms.

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

Modified: httpd/mod_python/trunk/lib/python/mod_python/cache.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/lib/python/mod_python/cache.py?rev=178147&r1=178146&r2=178147&view=diff
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/cache.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/cache.py Tue May 24 02:59:45 2005
@@ -1,4 +1,4 @@
- #
+#
  # Copyright 2004 Apache Software Foundation 
  # 
  # Licensed under the Apache License, Version 2.0 (the "License"); you
@@ -353,6 +353,8 @@
         finally:
             opened.close()
 
+re_not_word = re.compile(r'\W+')
+
 class ModuleCache(FileCache):
     """ A module cache. Give it a file name, it returns a module
         which results from the execution of the Python script it contains.
@@ -363,7 +365,7 @@
     
     def build(self, key, name, opened, entry):
         try:
-            module = new.module(key)
+            module = new.module(re_not_word.sub('_',key))
             module.__file__ = key
             exec opened in module.__dict__
             return module
@@ -380,7 +382,7 @@
     
     def build(self, key, name, opened, entry):
         try:
-            module = new.module(key)
+            module = new.module(re_not_word.sub('_',key))
             module.__file__ = key
             text = opened.read().replace('\r\n', '\n')
             code = compile(text, name, 'exec')