summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-07-03 01:36:19 -0400
committerChris McDonough <chrism@plope.com>2013-07-03 01:36:19 -0400
commitfc105d25af21589a5836c479684be0dc514adee3 (patch)
tree76fc77797b04f4a3d0316ae22d0aca5b2fabc035
parent050b71c19081d95c1fb8ed57a87fab7fa4dd3ab0 (diff)
parentd59440878b67b65e57c91c7b4aa8e7cbf943a729 (diff)
downloadpyramid-fc105d25af21589a5836c479684be0dc514adee3.tar.gz
pyramid-fc105d25af21589a5836c479684be0dc514adee3.tar.bz2
pyramid-fc105d25af21589a5836c479684be0dc514adee3.zip
Merge branch 'master' of github.com:Pylons/pyramid
-rw-r--r--.travis.yml1
-rw-r--r--CHANGES.txt3
-rw-r--r--README.rst4
-rw-r--r--pyramid/scripts/prequest.py23
-rw-r--r--pyramid/tests/test_scripts/test_prequest.py26
5 files changed, 47 insertions, 10 deletions
diff --git a/.travis.yml b/.travis.yml
index ab9c3ff30..00c293046 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,4 @@
+# Wire up travis
language: python
python:
diff --git a/CHANGES.txt b/CHANGES.txt
index 2c8c6ee46..ba8aae559 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,6 +4,9 @@ next release
Features
--------
+- ``scripts/prequest.py``: add support for submitting ``PUT`` and ``PATCH``
+ requests. See https://github.com/Pylons/pyramid/pull/1033.
+
- ``ACLAuthorizationPolicy`` supports ``__acl__`` as a callable. This
removes the ambiguity between the potential ``AttributeError`` that would
be raised on the ``context`` when the property was not defined and the
diff --git a/README.rst b/README.rst
index 4d427a13d..a3458028b 100644
--- a/README.rst
+++ b/README.rst
@@ -1,8 +1,8 @@
Pyramid
=======
-Pyramid is a small, fast, down-to-earth, open source Python web application
-development framework. It makes real-world web application development and
+Pyramid is a small, fast, down-to-earth, open source Python web framework.
+It makes real-world web application development and
deployment more fun, more predictable, and more productive.
Pyramid is produced by the `Pylons Project <http://pylonsproject.org/>`_.
diff --git a/pyramid/scripts/prequest.py b/pyramid/scripts/prequest.py
index da6b8cc14..3d8921b15 100644
--- a/pyramid/scripts/prequest.py
+++ b/pyramid/scripts/prequest.py
@@ -18,9 +18,16 @@ class PRequestCommand(object):
This command makes an artifical request to a web application that uses a
PasteDeploy (.ini) configuration file for the server and application.
- Use "prequest config.ini /path" to request "/path". Use "prequest
- --method=POST config.ini /path < data" to do a POST with the given
- request body.
+ Use "prequest config.ini /path" to request "/path".
+
+ Use "prequest --method=POST config.ini /path < data" to do a POST with
+ the given request body.
+
+ Use "prequest --method=PUT config.ini /path < data" to do a
+ PUT with the given request body.
+
+ Use "prequest --method=PATCH config.ini /path < data" to do a
+ PATCH with the given request body.
If the path is relative (doesn't begin with "/") it is interpreted as
relative to "/". The path passed to this script should be URL-quoted.
@@ -59,9 +66,9 @@ class PRequestCommand(object):
parser.add_option(
'-m', '--method',
dest='method',
- choices=['GET', 'HEAD', 'POST', 'DELETE'],
+ choices=['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'],
type='choice',
- help='Request method type (GET, POST, DELETE)',
+ help='Request method type',
)
get_app = staticmethod(get_app)
@@ -110,9 +117,9 @@ class PRequestCommand(object):
environ = {
'REQUEST_METHOD': request_method,
'SCRIPT_NAME': '', # may be empty if app is at the root
- 'PATH_INFO': path,
+ 'PATH_INFO': path,
'SERVER_NAME': 'localhost', # always mandatory
- 'SERVER_PORT': '80', # always mandatory
+ 'SERVER_PORT': '80', # always mandatory
'SERVER_PROTOCOL': 'HTTP/1.0',
'CONTENT_TYPE': 'text/plain',
'REMOTE_ADDR':'127.0.0.1',
@@ -127,7 +134,7 @@ class PRequestCommand(object):
'paste.command_request': True,
}
- if request_method == 'POST':
+ if request_method in ('POST', 'PUT', 'PATCH'):
environ['wsgi.input'] = self.stdin
environ['CONTENT_LENGTH'] = '-1'
diff --git a/pyramid/tests/test_scripts/test_prequest.py b/pyramid/tests/test_scripts/test_prequest.py
index 91d2b322a..64a7c3045 100644
--- a/pyramid/tests/test_scripts/test_prequest.py
+++ b/pyramid/tests/test_scripts/test_prequest.py
@@ -114,6 +114,32 @@ class TestPRequestCommand(unittest.TestCase):
self.assertEqual(self._app_name, None)
self.assertEqual(self._out, ['abc'])
+ def test_command_method_put(self):
+ from pyramid.compat import NativeIO
+ command = self._makeOne(['', '--method=PUT', 'development.ini', '/'])
+ stdin = NativeIO()
+ command.stdin = stdin
+ command.run()
+ self.assertEqual(self._environ['CONTENT_LENGTH'], '-1')
+ self.assertEqual(self._environ['wsgi.input'], stdin)
+ self.assertEqual(self._path_info, '/')
+ self.assertEqual(self._spec, 'development.ini')
+ self.assertEqual(self._app_name, None)
+ self.assertEqual(self._out, ['abc'])
+
+ def test_command_method_patch(self):
+ from pyramid.compat import NativeIO
+ command = self._makeOne(['', '--method=PATCH', 'development.ini', '/'])
+ stdin = NativeIO()
+ command.stdin = stdin
+ command.run()
+ self.assertEqual(self._environ['CONTENT_LENGTH'], '-1')
+ self.assertEqual(self._environ['wsgi.input'], stdin)
+ self.assertEqual(self._path_info, '/')
+ self.assertEqual(self._spec, 'development.ini')
+ self.assertEqual(self._app_name, None)
+ self.assertEqual(self._out, ['abc'])
+
def test_command_with_query_string(self):
command = self._makeOne(['', 'development.ini', '/abc?a=1&b=2&c'])
command.run()