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/13 08:57:18 UTC

svn commit: r169959 - in /httpd/mod_python/trunk/lib/python/mod_python: cache.py publisher.py

Author: nlehuen
Date: Thu May 12 23:57:17 2005
New Revision: 169959

URL: http://svn.apache.org/viewcvs?rev=169959&view=rev
Log:
Working on MODPYTHON-54 - this does not work yet, but it does not break anything.

Modified:
    httpd/mod_python/trunk/lib/python/mod_python/cache.py
    httpd/mod_python/trunk/lib/python/mod_python/publisher.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=169959&r1=169958&r2=169959&view=diff
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/cache.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/cache.py Thu May 12 23:57:17 2005
@@ -362,6 +362,7 @@
     
     def build(self,name,opened,entry):
         try:
+            name = self.key(name)
             module = Module(name)
             exec opened in module.__dict__
             return module

Modified: httpd/mod_python/trunk/lib/python/mod_python/publisher.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/lib/python/mod_python/publisher.py?rev=169959&r1=169958&r2=169959&view=diff
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/publisher.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/publisher.py Thu May 12 23:57:17 2005
@@ -74,6 +74,31 @@
 
 page_cache = PageCache()
 
+class DummyRequest(object):
+    """
+        This class is used to simulate a request object to be able to import
+        an arbitrary module from the page cache.
+    """
+    def __init__(self,filename):
+        self.filename = filename
+        
+    def get_config(self):
+        return {}
+        
+    def log_error(self,message,level):
+        apache.log_error(message,level)
+
+def import_page(absolute_path):
+    req = DummyRequest(absolute_path)
+    return page_cache[req]
+
+def get_page(req,relative_path):
+    real_filename = req.filename
+    try:
+        return page_cache[req]
+    finally:
+        req.filename = real_filename
+
 def handler(req):
 
     req.allow_methods(["GET", "POST", "HEAD"])