← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~james-w/python-oops-wsgi/allow-int-port into lp:python-oops-wsgi

 

James Westby has proposed merging lp:~james-w/python-oops-wsgi/allow-int-port into lp:python-oops-wsgi.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~james-w/python-oops-wsgi/allow-int-port/+merge/228178

Hi,

This drops paste from oops.

Thanks,

James

-- 
https://code.launchpad.net/~james-w/python-oops-wsgi/allow-int-port/+merge/228178
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~james-w/python-oops-wsgi/allow-int-port into lp:python-oops-wsgi.
=== modified file 'README'
--- README	2011-11-13 21:57:57 +0000
+++ README	2014-07-24 17:50:03 +0000
@@ -27,8 +27,6 @@
 
 * oops (http://pypi.python.org/pypi/oops)
 
-* paste
-
 Testing Dependencies
 ====================
 

=== modified file 'buildout.cfg'
--- buildout.cfg	2011-11-13 21:57:57 +0000
+++ buildout.cfg	2014-07-24 17:50:03 +0000
@@ -34,6 +34,5 @@
 eggs = oops-wsgi [test]
 include-site-packages = true
 allowed-eggs-from-site-packages = 
-    paste
     subunit
 interpreter = py

=== modified file 'oops_wsgi/middleware.py'
--- oops_wsgi/middleware.py	2013-05-22 15:59:31 +0000
+++ oops_wsgi/middleware.py	2014-07-24 17:50:03 +0000
@@ -20,8 +20,7 @@
 import socket
 import sys
 import time
-
-from paste.request import construct_url
+from urllib import quote
 
 __all__ = [
     'default_map_environ',
@@ -253,3 +252,61 @@
     finally:
         if hasattr(app_body, 'close'):
             app_body.close()
+
+
+# construct_url is taken from paste.request, which is licensed:
+# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
+# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
+#
+# It is modifed to use str() around environ['SERVER_PORT'] due to
+# https://github.com/benoitc/gunicorn/issues/271
+def construct_url(environ, with_query_string=True, with_path_info=True,
+                  script_name=None, path_info=None, querystring=None):
+    """Reconstructs the URL from the WSGI environment.
+
+    You may override SCRIPT_NAME, PATH_INFO, and QUERYSTRING with
+    the keyword arguments.
+
+    """
+    url = environ['wsgi.url_scheme']+'://'
+
+    if environ.get('HTTP_HOST'):
+        host = environ['HTTP_HOST']
+        port = None
+        if ':' in host:
+            host, port = host.split(':', 1)
+            if environ['wsgi.url_scheme'] == 'https':
+                if port == '443':
+                    port = None
+            elif environ['wsgi.url_scheme'] == 'http':
+                if port == '80':
+                    port = None
+        url += host
+        if port:
+            url += ':%s' % port
+    else:
+        url += environ['SERVER_NAME']
+        server_port = str(environ['SERVER_PORT'])
+        if environ['wsgi.url_scheme'] == 'https':
+            if server_port != '443':
+                url += ':' + server_port
+        else:
+            if server_port != '80':
+                url += ':' + server_port
+
+    if script_name is None:
+        url += quote(environ.get('SCRIPT_NAME',''))
+    else:
+        url += quote(script_name)
+    if with_path_info:
+        if path_info is None:
+            url += quote(environ.get('PATH_INFO',''))
+        else:
+            url += quote(path_info)
+    if with_query_string:
+        if querystring is None:
+            if environ.get('QUERY_STRING'):
+                url += '?' + environ['QUERY_STRING']
+        elif querystring:
+            url += '?' + querystring
+    return url

=== modified file 'setup.py'
--- setup.py	2014-05-06 15:37:19 +0000
+++ setup.py	2014-07-24 17:50:03 +0000
@@ -41,7 +41,6 @@
           ],
       install_requires = [
           'oops',
-          'paste',
           ],
       extras_require = dict(
           test=[

=== modified file 'versions.cfg'
--- versions.cfg	2011-08-17 08:05:47 +0000
+++ versions.cfg	2014-07-24 17:50:03 +0000
@@ -5,7 +5,6 @@
 fixtures = 0.3.6
 iso8601 = 0.1.4
 oops = 0.0.6
-paste = 1.7.2
 pytz = 2010o
 setuptools = 0.6c11
 testtools = 0.9.11


Follow ups