diff options
| author | Chris McDonough <chrism@plope.com> | 2011-12-21 02:08:00 -0500 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-12-21 02:08:00 -0500 |
| commit | 790fa66970764fb84dfb2fbbc0a71a5610406181 (patch) | |
| tree | 76b2d8ac49aea6774d01f051cec1f93f140ea4e6 | |
| parent | ba2a3f87fa51843a8a160f209fb576ae21d0050b (diff) | |
| parent | 61d45f9f3d02f0bdf615a2c266e7f4060c833a3e (diff) | |
| download | pyramid-790fa66970764fb84dfb2fbbc0a71a5610406181.tar.gz pyramid-790fa66970764fb84dfb2fbbc0a71a5610406181.tar.bz2 pyramid-790fa66970764fb84dfb2fbbc0a71a5610406181.zip | |
merge master to 1.3 branch
| -rw-r--r-- | TODO.txt | 6 | ||||
| -rw-r--r-- | docs/narr/commandline.rst | 8 | ||||
| -rw-r--r-- | pyramid/scripts/prequest.py | 30 | ||||
| -rw-r--r-- | pyramid/tests/test_scripts/test_prequest.py | 8 |
4 files changed, 26 insertions, 26 deletions
@@ -28,6 +28,12 @@ Nice-to-Have * introspection hiding for directives? +- Fix deployment recipes in cookbook (discourage proxying without changing + server). + +Nice-to-Have +------------ + - CherryPy server testing / exploded from CherryPy itself. - Try "with transaction.manager" in an exception view with SQLA (preempt diff --git a/docs/narr/commandline.rst b/docs/narr/commandline.rst index dc3cff8ac..b42a7ae9e 100644 --- a/docs/narr/commandline.rst +++ b/docs/narr/commandline.rst @@ -793,10 +793,10 @@ top-level directory your ``setup.py`` file will look something like this: zip_safe=False, install_requires=requires, tests_require=requires, - test_suite="wiggystatic", + test_suite="myproject", entry_points = """\ [paste.app_factory] - main = wiggystatic:main + main = myproject:main """, ) @@ -848,10 +848,10 @@ The result will be something like: zip_safe=False, install_requires=requires, tests_require=requires, - test_suite="wiggystatic", + test_suite="myproject", entry_points = """\ [paste.app_factory] - main = wiggystatic:main + main = myproject:main [console_scripts] show_settings = myproject.scripts:settings_show """, diff --git a/pyramid/scripts/prequest.py b/pyramid/scripts/prequest.py index 073323cd6..a102dda7e 100644 --- a/pyramid/scripts/prequest.py +++ b/pyramid/scripts/prequest.py @@ -2,7 +2,7 @@ import optparse import sys import textwrap -from pyramid.compat import url_quote +from pyramid.compat import url_unquote from pyramid.request import Request from pyramid.paster import get_app @@ -22,15 +22,12 @@ class PRequestCommand(object): request body. If the path is relative (doesn't begin with "/") it is interpreted as - relative to "/". + relative to "/". The path passed to this script should be URL-quoted. + The path can be succeeded with a query string (e.g. `/path?a=1&=b2'). The variable "environ['paste.command_request']" will be set to "True" in the request's WSGI environment, so your application can distinguish these calls from normal requests. - - Note that you can pass arguments besides the options listed here; any - unknown arguments will be passed to the application in - "environ['QUERY_STRING']" """ usage = "usage: %prog config_uri path_info [args/options]" parser = optparse.OptionParser( @@ -84,7 +81,14 @@ class PRequestCommand(object): app_spec = self.args[0] path = self.args[1] if not path.startswith('/'): - path = '/' + path + path = '/' + path + + try: + path, qs = path.split('?', 1) + except ValueError: + qs = '' + + path = url_unquote(path) headers = {} if self.options.headers: @@ -100,20 +104,10 @@ class PRequestCommand(object): app = self.get_app(app_spec, self.options.app_name) request_method = (self.options.method or 'GET').upper() - qs = [] - for item in self.args[2:]: - if '=' in item: - k, v = item.split('=', 1) - item = url_quote(k) + '=' + url_quote(v) - else: - item = url_quote(item) - qs.append(item) - qs = '&'.join(qs) - environ = { 'REQUEST_METHOD': request_method, 'SCRIPT_NAME': '', # may be empty if app is at the root - 'PATH_INFO': path, # may be empty if at root of app + 'PATH_INFO': path, 'SERVER_NAME': 'localhost', # always mandatory 'SERVER_PORT': '80', # always mandatory 'SERVER_PROTOCOL': 'HTTP/1.0', diff --git a/pyramid/tests/test_scripts/test_prequest.py b/pyramid/tests/test_scripts/test_prequest.py index 34c4b3591..7f24174ef 100644 --- a/pyramid/tests/test_scripts/test_prequest.py +++ b/pyramid/tests/test_scripts/test_prequest.py @@ -111,11 +111,11 @@ class TestPRequestCommand(unittest.TestCase): self.assertEqual(self._app_name, None) self.assertEqual(self._out, ['abc']) - def test_command_extra_args_used_in_query_string(self): - command = self._makeOne(['', 'development.ini', '/', 'a=1%','b=2','c']) + def test_command_with_query_string(self): + command = self._makeOne(['', 'development.ini', '/abc?a=1&b=2&c']) command.run() - self.assertEqual(self._environ['QUERY_STRING'], 'a=1%25&b=2&c') - self.assertEqual(self._path_info, '/') + self.assertEqual(self._environ['QUERY_STRING'], 'a=1&b=2&c') + self.assertEqual(self._path_info, '/abc') self.assertEqual(self._spec, 'development.ini') self.assertEqual(self._app_name, None) self.assertEqual(self._out, ['abc']) |
