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/27 07:22:29 UTC

svn commit: r397404 - in /httpd/mod_python/trunk: Doc/appendixc.tex Doc/modpython4.tex lib/python/mod_python/Session.py lib/python/mod_python/__init__.py src/include/mpversion.h test/test.py

Author: grahamd
Date: Wed Apr 26 22:22:27 2006
New Revision: 397404

URL: http://svn.apache.org/viewcvs?rev=397404&view=rev
Log:
Added support for cross domain session objects. (MODPYTHON-149)

Modified:
    httpd/mod_python/trunk/Doc/appendixc.tex
    httpd/mod_python/trunk/Doc/modpython4.tex
    httpd/mod_python/trunk/lib/python/mod_python/Session.py
    httpd/mod_python/trunk/lib/python/mod_python/__init__.py
    httpd/mod_python/trunk/src/include/mpversion.h
    httpd/mod_python/trunk/test/test.py

Modified: httpd/mod_python/trunk/Doc/appendixc.tex
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/Doc/appendixc.tex?rev=397404&r1=397403&r2=397404&view=diff
==============================================================================
--- httpd/mod_python/trunk/Doc/appendixc.tex (original)
+++ httpd/mod_python/trunk/Doc/appendixc.tex Wed Apr 26 22:22:27 2006
@@ -75,6 +75,9 @@
       similar function provided by Apache C API. The function tests for
       and reads any message body in the request, simply discarding
       whatever it receives.
+    \item
+      (\citetitle[http://issues.apache.org/jira/browse/MODPYTHON-149]{MODPYTHON-149})
+      Added support for session objects that span domains.
   \end{itemize}
 
   Improvements

Modified: httpd/mod_python/trunk/Doc/modpython4.tex
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/Doc/modpython4.tex?rev=397404&r1=397403&r2=397404&view=diff
==============================================================================
--- httpd/mod_python/trunk/Doc/modpython4.tex (original)
+++ httpd/mod_python/trunk/Doc/modpython4.tex Wed Apr 26 22:22:27 2006
@@ -2250,6 +2250,13 @@
   \code{ApplicationPath} option (\samp{PythonOption ApplicationPath
   /my/path} in server configuration).
 
+  The domain of a cookie is by default not set for a session and as such
+  the session is only valid for the host which generated it. In order to
+  have a session which spans across common sub domains, you can specify the
+  parent domain using the \code{mod_python.session.application_domain}
+  option (\samp{PythonOption mod_python.session.application_domain
+  mod_python.org} in server configuration).
+
   When a \var{secret} is provided, \class{BaseSession} will use
   \class{SignedCookie} when generating cookies thereby making the
   session id almost impossible to fake. The default is to use plain

Modified: httpd/mod_python/trunk/lib/python/mod_python/Session.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/lib/python/mod_python/Session.py?rev=397404&r1=397403&r2=397404&view=diff
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/Session.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/Session.py Wed Apr 26 22:22:27 2006
@@ -194,6 +194,8 @@
             c = Cookie.Cookie(session_cookie_name, self._sid)
 
         config = self._req.get_options()
+        if config.has_key("mod_python.session.application_domain"): 
+            c.domain = config["mod_python.session.application_domain"] 
         if config.has_key("ApplicationPath"):
             c.path = config["ApplicationPath"]
         else:

Modified: httpd/mod_python/trunk/lib/python/mod_python/__init__.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/lib/python/mod_python/__init__.py?rev=397404&r1=397403&r2=397404&view=diff
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/__init__.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/__init__.py Wed Apr 26 22:22:27 2006
@@ -20,5 +20,5 @@
 __all__ = ["apache", "cgihandler", "psp",
            "publisher", "util", "python22"]
 
-version = "3.3.0-dev-20060425"
+version = "3.3.0-dev-20060427"
 

Modified: httpd/mod_python/trunk/src/include/mpversion.h
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/src/include/mpversion.h?rev=397404&r1=397403&r2=397404&view=diff
==============================================================================
--- httpd/mod_python/trunk/src/include/mpversion.h (original)
+++ httpd/mod_python/trunk/src/include/mpversion.h Wed Apr 26 22:22:27 2006
@@ -1,5 +1,5 @@
 #define MPV_MAJOR 3
 #define MPV_MINOR 3
 #define MPV_PATCH 0
-#define MPV_BUILD 20060425
-#define MPV_STRING "3.3.0-dev-20060425"
+#define MPV_BUILD 20060427
+#define MPV_STRING "3.3.0-dev-20060427"

Modified: httpd/mod_python/trunk/test/test.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/test/test.py?rev=397404&r1=397403&r2=397404&view=diff
==============================================================================
--- httpd/mod_python/trunk/test/test.py (original)
+++ httpd/mod_python/trunk/test/test.py Wed Apr 26 22:22:27 2006
@@ -1928,6 +1928,8 @@
                                   SetHandler("mod_python"),
                                   PythonHandler("tests::Session_Session"),
                                   PythonOption('session_directory "%s"' % TMP_DIR),
+                                  PythonOption('ApplicationPath "/path"'),
+                                  PythonOption('mod_python.session.application_domain "test_Session_Session"'),
                                   PythonDebug("On")))
         return str(c)
 
@@ -1946,6 +1948,18 @@
 
         if rsp != "test ok" or setcookie == None:
             self.fail("session did not set a cookie")
+
+        parts = setcookie.split('; ')
+        fields = {}
+        for part in parts:
+          key, value = part.split('=')
+          fields[key] = value
+
+        if not fields.has_key('path') or fields['path'] != '/path':
+            self.fail("session did not contain expected 'path'")
+
+        if not fields.has_key('domain') or fields['domain'] != 'test_Session_Session':
+            self.fail("session did not contain expected 'domain'")
 
         conn = httplib.HTTPConnection("127.0.0.1:%s" % PORT)
         conn.putrequest("GET", "/tests.py", skip_host=1)