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 jg...@apache.org on 2006/03/05 19:40:23 UTC
svn commit: r383365 - in /httpd/mod_python/branches/3.2.x: src/connobject.c
src/filterobject.c test/httpdconf.py test/test.py
Author: jgallacher
Date: Sun Mar 5 10:40:22 2006
New Revision: 383365
URL: http://svn.apache.org/viewcvs?rev=383365&view=rev
Log:
Backported Apache 2.2 support from trunk. (MODPYTHON-78)
Modified:
httpd/mod_python/branches/3.2.x/src/connobject.c
httpd/mod_python/branches/3.2.x/src/filterobject.c
httpd/mod_python/branches/3.2.x/test/httpdconf.py
httpd/mod_python/branches/3.2.x/test/test.py
Modified: httpd/mod_python/branches/3.2.x/src/connobject.c
URL: http://svn.apache.org/viewcvs/httpd/mod_python/branches/3.2.x/src/connobject.c?rev=383365&r1=383364&r2=383365&view=diff
==============================================================================
--- httpd/mod_python/branches/3.2.x/src/connobject.c (original)
+++ httpd/mod_python/branches/3.2.x/src/connobject.c Sun Mar 5 10:40:22 2006
@@ -79,7 +79,7 @@
rc = ap_get_brigade(c->input_filters, bb, mode, APR_BLOCK_READ, bufsize);
Py_END_ALLOW_THREADS;
- if (! APR_STATUS_IS_SUCCESS(rc)) {
+ if (rc != APR_SUCCESS) {
PyErr_SetObject(PyExc_IOError,
PyString_FromString("Connection read error"));
return NULL;
@@ -319,14 +319,14 @@
{
PyObject *addrobj = makeipaddr(addr);
PyObject *ret = NULL;
+
+ /* apr_sockaddr_port_get was deprecated and removed in apr 1.x
+ * Access the port directly instead
+ */
if (addrobj) {
apr_port_t port;
- if(apr_sockaddr_port_get(&port, addr)==APR_SUCCESS) {
- ret = Py_BuildValue("Oi", addrobj, port );
- }
- else {
- PyErr_SetString(PyExc_SystemError,"apr_sockaddr_port_get failure");
- }
+ port = addr->port;
+ ret = Py_BuildValue("Oi", addrobj, port );
Py_DECREF(addrobj);
}
return ret;
Modified: httpd/mod_python/branches/3.2.x/src/filterobject.c
URL: http://svn.apache.org/viewcvs/httpd/mod_python/branches/3.2.x/src/filterobject.c?rev=383365&r1=383364&r2=383365&view=diff
==============================================================================
--- httpd/mod_python/branches/3.2.x/src/filterobject.c (original)
+++ httpd/mod_python/branches/3.2.x/src/filterobject.c Sun Mar 5 10:40:22 2006
@@ -178,7 +178,7 @@
APR_BLOCK_READ, self->readbytes);
Py_END_ALLOW_THREADS;
- if (!APR_STATUS_IS_EAGAIN(self->rc) && !APR_STATUS_IS_SUCCESS(self->rc)) {
+ if (!APR_STATUS_IS_EAGAIN(self->rc) && !(self->rc == APR_SUCCESS)) {
PyErr_SetObject(PyExc_IOError,
PyString_FromString("Input filter read error"));
return NULL;
Modified: httpd/mod_python/branches/3.2.x/test/httpdconf.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/branches/3.2.x/test/httpdconf.py?rev=383365&r1=383364&r2=383365&view=diff
==============================================================================
--- httpd/mod_python/branches/3.2.x/test/httpdconf.py (original)
+++ httpd/mod_python/branches/3.2.x/test/httpdconf.py Sun Mar 5 10:40:22 2006
@@ -37,8 +37,11 @@
class Container:
def __init__(self, *args):
- self.args = args
+ self.args = list(args)
self.indent = 0
+
+ def append(self, value):
+ self.args.append(value)
def __str__(self):
@@ -80,6 +83,16 @@
def __init__(self, val):
Directive.__init__(self, self.__class__.__name__, val)
+class AuthBasicAuthoritative(Directive):
+ # New in Apache 2.2
+ def __init__(self, val):
+ Directive.__init__(self, self.__class__.__name__, val)
+
+class AuthBasicProvider(Directive):
+ # New in Apache 2.2
+ def __init__(self, val):
+ Directive.__init__(self, self.__class__.__name__, val)
+
class AuthType(Directive):
def __init__(self, val):
Directive.__init__(self, self.__class__.__name__, val)
@@ -111,6 +124,10 @@
class IfModule(ContainerTag):
def __init__(self, dir, *args):
ContainerTag.__init__(self, self.__class__.__name__, dir, args)
+
+class KeepAliveTimeout(Directive):
+ def __init__(self, val):
+ Directive.__init__(self, self.__class__.__name__, val)
class Listen(Directive):
def __init__(self, val):
Modified: httpd/mod_python/branches/3.2.x/test/test.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/branches/3.2.x/test/test.py?rev=383365&r1=383364&r2=383365&view=diff
==============================================================================
--- httpd/mod_python/branches/3.2.x/test/test.py (original)
+++ httpd/mod_python/branches/3.2.x/test/test.py Sun Mar 5 10:40:22 2006
@@ -220,6 +220,32 @@
s = '"%s"' % s
return s
+def get_apache_version():
+
+ print "Checking Apache version...."
+ httpd = quoteIfSpace(HTTPD)
+ cmd = '%s -v' % (httpd)
+ (stdin,stdout) = os.popen2(cmd)
+
+ version_str = None
+ for line in stdout:
+ if line.startswith('Server version'):
+ version_str = line.strip()
+ break
+
+ if version_str:
+ version_str = version_str.split('/')[1]
+ major,minor,patch = version_str.split('.',3)
+ version = '%s.%s' % (major,minor)
+ else:
+
+ print "Can't determine Apache version. Assuming 2.0"
+ version = '2.0'
+ print version
+ return version
+
+APACHE_VERSION = get_apache_version()
+
class HttpdCtrl:
# a mixin providing ways to control httpd
@@ -289,14 +315,26 @@
Listen(PORT),
PythonOption('PythonOptionTest sample_value'),
DocumentRoot(DOCUMENT_ROOT),
- LoadModule("python_module %s" % quoteIfSpace(MOD_PYTHON_SO)),
- IfModule("!mod_auth.c",
+ LoadModule("python_module %s" % quoteIfSpace(MOD_PYTHON_SO)))
+
+ if APACHE_VERSION == '2.2':
+ # mod_auth has been split into mod_auth_basic and some other modules
+ s.append(IfModule("!mod_auth_basic.c",
+ LoadModule("auth_basic_module %s" %
+ quoteIfSpace(os.path.join(modpath, "mod_auth_basic.so")))))
+
+ # Default KeepAliveTimeout is 5 for apache 2.2, but 15 in apache 2.0
+ # Explicitly set the value so it's the same as 2.0
+ s.append(KeepAliveTimeout("15"))
+ else:
+ s.append(IfModule("!mod_auth.c",
LoadModule("auth_module %s" %
quoteIfSpace(os.path.join(modpath, "mod_auth.so")))))
+ s.append("\n# --APPENDED-- \n\n"+append)
+
f = open(CONFIG, "w")
f.write(str(s))
- f.write("\n# --APPENDED-- \n\n"+append)
f.close()
def startHttpd(self,extra=''):
@@ -595,7 +633,26 @@
def test_req_requires_conf(self):
- c = VirtualHost("*",
+ if APACHE_VERSION == '2.2':
+ # Apache 2.2 needs AuthBasicAuthoritative Off
+ # This is necessary when combining mod_auth_basic with third-party
+ # modules that are not configured with the AuthBasicProvider
+ # directive.
+ c = VirtualHost("*",
+ ServerName("test_req_requires"),
+ DocumentRoot(DOCUMENT_ROOT),
+ Directory(DOCUMENT_ROOT,
+ SetHandler("mod_python"),
+ AuthName("blah"),
+ AuthType("basic"),
+ Require("valid-user"),
+ AuthBasicAuthoritative("Off"),
+ PythonAuthenHandler("tests::req_requires"),
+ PythonDebug("On")))
+
+ else:
+ # This configuration is suitable for Apache 2.0
+ c = VirtualHost("*",
ServerName("test_req_requires"),
DocumentRoot(DOCUMENT_ROOT),
Directory(DOCUMENT_ROOT,
@@ -605,6 +662,7 @@
Require("valid-user"),
PythonAuthenHandler("tests::req_requires"),
PythonDebug("On")))
+
return str(c)
def test_req_requires(self):