From 45f5751cdf8f88ff77f4bd9c30a2f97dcac1b6e0 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Tue, 20 Mar 2012 14:46:49 +0100 Subject: generate more common filenames for sqlite --- pyramid/scaffolds/alchemy/development.ini_tmpl | 2 +- pyramid/scaffolds/alchemy/production.ini_tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyramid/scaffolds/alchemy/development.ini_tmpl b/pyramid/scaffolds/alchemy/development.ini_tmpl index bcba06c1c..eebfbcc3e 100644 --- a/pyramid/scaffolds/alchemy/development.ini_tmpl +++ b/pyramid/scaffolds/alchemy/development.ini_tmpl @@ -10,7 +10,7 @@ pyramid.includes = pyramid_debugtoolbar pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/{{project}}.db +sqlalchemy.url = sqlite:///%(here)s/{{project}}.sqlite [server:main] use = egg:waitress#main diff --git a/pyramid/scaffolds/alchemy/production.ini_tmpl b/pyramid/scaffolds/alchemy/production.ini_tmpl index dc9145d12..9488f1811 100644 --- a/pyramid/scaffolds/alchemy/production.ini_tmpl +++ b/pyramid/scaffolds/alchemy/production.ini_tmpl @@ -9,7 +9,7 @@ pyramid.default_locale_name = en pyramid.includes = pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/{{project}}.db +sqlalchemy.url = sqlite:///%(here)s/{{project}}.sqlite [server:main] use = egg:waitress#main -- cgit v1.2.3 From 4e3de46840501d20472e5e54510ed598906c0b21 Mon Sep 17 00:00:00 2001 From: Toni Mueller Date: Tue, 20 Mar 2012 14:46:49 +0100 Subject: generate more common filenames for sqlite and patch the wiki2 tutorial, too --- docs/tutorials/wiki2/installation.rst | 2 +- docs/tutorials/wiki2/src/authorization/development.ini | 2 +- docs/tutorials/wiki2/src/authorization/production.ini | 2 +- docs/tutorials/wiki2/src/basiclayout/development.ini | 2 +- docs/tutorials/wiki2/src/basiclayout/production.ini | 2 +- docs/tutorials/wiki2/src/models/development.ini | 2 +- docs/tutorials/wiki2/src/models/production.ini | 2 +- docs/tutorials/wiki2/src/tests/development.ini | 2 +- docs/tutorials/wiki2/src/tests/production.ini | 2 +- docs/tutorials/wiki2/src/views/development.ini | 2 +- docs/tutorials/wiki2/src/views/production.ini | 2 +- pyramid/scaffolds/alchemy/development.ini_tmpl | 2 +- pyramid/scaffolds/alchemy/production.ini_tmpl | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index 4ee2728c2..40486057e 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -254,7 +254,7 @@ The output to your console should be something like this:: 2011-11-26 14:42:25,140 INFO [sqlalchemy.engine.base.Engine][MainThread] COMMIT -Success! You should now have a ``tutorial.db`` file in your current working +Success! You should now have a ``tutorial.sqlite`` file in your current working directory. This will be a SQLite database with a single table defined in it (``models``). diff --git a/docs/tutorials/wiki2/src/authorization/development.ini b/docs/tutorials/wiki2/src/authorization/development.ini index 38738f3c6..eb2f878c5 100644 --- a/docs/tutorials/wiki2/src/authorization/development.ini +++ b/docs/tutorials/wiki2/src/authorization/development.ini @@ -10,7 +10,7 @@ pyramid.includes = pyramid_debugtoolbar pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/tutorial.db +sqlalchemy.url = sqlite:///%(here)s/tutorial.sqlite [server:main] use = egg:waitress#main diff --git a/docs/tutorials/wiki2/src/authorization/production.ini b/docs/tutorials/wiki2/src/authorization/production.ini index c4034abad..4684d2f7a 100644 --- a/docs/tutorials/wiki2/src/authorization/production.ini +++ b/docs/tutorials/wiki2/src/authorization/production.ini @@ -9,7 +9,7 @@ pyramid.default_locale_name = en pyramid.includes = pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/tutorial.db +sqlalchemy.url = sqlite:///%(here)s/tutorial.sqlite [server:main] use = egg:waitress#main diff --git a/docs/tutorials/wiki2/src/basiclayout/development.ini b/docs/tutorials/wiki2/src/basiclayout/development.ini index 38738f3c6..eb2f878c5 100644 --- a/docs/tutorials/wiki2/src/basiclayout/development.ini +++ b/docs/tutorials/wiki2/src/basiclayout/development.ini @@ -10,7 +10,7 @@ pyramid.includes = pyramid_debugtoolbar pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/tutorial.db +sqlalchemy.url = sqlite:///%(here)s/tutorial.sqlite [server:main] use = egg:waitress#main diff --git a/docs/tutorials/wiki2/src/basiclayout/production.ini b/docs/tutorials/wiki2/src/basiclayout/production.ini index c4034abad..4684d2f7a 100644 --- a/docs/tutorials/wiki2/src/basiclayout/production.ini +++ b/docs/tutorials/wiki2/src/basiclayout/production.ini @@ -9,7 +9,7 @@ pyramid.default_locale_name = en pyramid.includes = pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/tutorial.db +sqlalchemy.url = sqlite:///%(here)s/tutorial.sqlite [server:main] use = egg:waitress#main diff --git a/docs/tutorials/wiki2/src/models/development.ini b/docs/tutorials/wiki2/src/models/development.ini index 38738f3c6..eb2f878c5 100644 --- a/docs/tutorials/wiki2/src/models/development.ini +++ b/docs/tutorials/wiki2/src/models/development.ini @@ -10,7 +10,7 @@ pyramid.includes = pyramid_debugtoolbar pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/tutorial.db +sqlalchemy.url = sqlite:///%(here)s/tutorial.sqlite [server:main] use = egg:waitress#main diff --git a/docs/tutorials/wiki2/src/models/production.ini b/docs/tutorials/wiki2/src/models/production.ini index c4034abad..4684d2f7a 100644 --- a/docs/tutorials/wiki2/src/models/production.ini +++ b/docs/tutorials/wiki2/src/models/production.ini @@ -9,7 +9,7 @@ pyramid.default_locale_name = en pyramid.includes = pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/tutorial.db +sqlalchemy.url = sqlite:///%(here)s/tutorial.sqlite [server:main] use = egg:waitress#main diff --git a/docs/tutorials/wiki2/src/tests/development.ini b/docs/tutorials/wiki2/src/tests/development.ini index 38738f3c6..eb2f878c5 100644 --- a/docs/tutorials/wiki2/src/tests/development.ini +++ b/docs/tutorials/wiki2/src/tests/development.ini @@ -10,7 +10,7 @@ pyramid.includes = pyramid_debugtoolbar pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/tutorial.db +sqlalchemy.url = sqlite:///%(here)s/tutorial.sqlite [server:main] use = egg:waitress#main diff --git a/docs/tutorials/wiki2/src/tests/production.ini b/docs/tutorials/wiki2/src/tests/production.ini index c4034abad..4684d2f7a 100644 --- a/docs/tutorials/wiki2/src/tests/production.ini +++ b/docs/tutorials/wiki2/src/tests/production.ini @@ -9,7 +9,7 @@ pyramid.default_locale_name = en pyramid.includes = pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/tutorial.db +sqlalchemy.url = sqlite:///%(here)s/tutorial.sqlite [server:main] use = egg:waitress#main diff --git a/docs/tutorials/wiki2/src/views/development.ini b/docs/tutorials/wiki2/src/views/development.ini index 38738f3c6..eb2f878c5 100644 --- a/docs/tutorials/wiki2/src/views/development.ini +++ b/docs/tutorials/wiki2/src/views/development.ini @@ -10,7 +10,7 @@ pyramid.includes = pyramid_debugtoolbar pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/tutorial.db +sqlalchemy.url = sqlite:///%(here)s/tutorial.sqlite [server:main] use = egg:waitress#main diff --git a/docs/tutorials/wiki2/src/views/production.ini b/docs/tutorials/wiki2/src/views/production.ini index c4034abad..4684d2f7a 100644 --- a/docs/tutorials/wiki2/src/views/production.ini +++ b/docs/tutorials/wiki2/src/views/production.ini @@ -9,7 +9,7 @@ pyramid.default_locale_name = en pyramid.includes = pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/tutorial.db +sqlalchemy.url = sqlite:///%(here)s/tutorial.sqlite [server:main] use = egg:waitress#main diff --git a/pyramid/scaffolds/alchemy/development.ini_tmpl b/pyramid/scaffolds/alchemy/development.ini_tmpl index bcba06c1c..eebfbcc3e 100644 --- a/pyramid/scaffolds/alchemy/development.ini_tmpl +++ b/pyramid/scaffolds/alchemy/development.ini_tmpl @@ -10,7 +10,7 @@ pyramid.includes = pyramid_debugtoolbar pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/{{project}}.db +sqlalchemy.url = sqlite:///%(here)s/{{project}}.sqlite [server:main] use = egg:waitress#main diff --git a/pyramid/scaffolds/alchemy/production.ini_tmpl b/pyramid/scaffolds/alchemy/production.ini_tmpl index dc9145d12..9488f1811 100644 --- a/pyramid/scaffolds/alchemy/production.ini_tmpl +++ b/pyramid/scaffolds/alchemy/production.ini_tmpl @@ -9,7 +9,7 @@ pyramid.default_locale_name = en pyramid.includes = pyramid_tm -sqlalchemy.url = sqlite:///%(here)s/{{project}}.db +sqlalchemy.url = sqlite:///%(here)s/{{project}}.sqlite [server:main] use = egg:waitress#main -- cgit v1.2.3 From aca78fe3f08ad31be2cc154301c95a318d74ead8 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 18 Apr 2012 14:47:51 -0400 Subject: break docs stuff out of testing to hopefully appease shiningpanda --- setup.cfg | 2 +- setup.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/setup.cfg b/setup.cfg index 8aac0afd1..d7622683f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,4 +10,4 @@ cover-erase=1 [aliases] dev = develop easy_install pyramid[testing] - +docs = develop easy_install pyramid[docs] diff --git a/setup.py b/setup.py index e325b8a29..29a0f22ca 100644 --- a/setup.py +++ b/setup.py @@ -49,19 +49,22 @@ install_requires=[ ] tests_require = [ + 'nose', + 'coverage', 'WebTest >= 1.3.1', # py3 compat 'virtualenv', ] if not PY3: tests_require.extend([ - 'Sphinx', - 'docutils', - 'repoze.sphinx.autointerface', 'zope.component>=3.11.0', ]) -testing_extras = tests_require + ['nose', 'coverage'] +docs_extras = [ + 'Sphinx', + 'docutils', + 'repoze.sphinx.autointerface', + ] setup(name='pyramid', version='1.4dev', @@ -92,7 +95,8 @@ setup(name='pyramid', zip_safe=False, install_requires = install_requires, extras_require = { - 'testing':testing_extras, + 'testing':tests_require, + 'docs':docs_extras, }, tests_require = tests_require, test_suite="pyramid.tests", -- cgit v1.2.3 From ff5a6a6b039c04f8d55c3ab513257d2aff8d5e9e Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 18 Apr 2012 15:42:13 -0400 Subject: try to fix windows test failure --- pyramid/tests/test_scaffolds/test_copydir.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyramid/tests/test_scaffolds/test_copydir.py b/pyramid/tests/test_scaffolds/test_copydir.py index 42edd9d23..68cefbe6e 100644 --- a/pyramid/tests/test_scaffolds/test_copydir.py +++ b/pyramid/tests/test_scaffolds/test_copydir.py @@ -170,9 +170,11 @@ class Test_makedirs(unittest.TestCase): def test_makedirs_parent_dir(self): import shutil - target = "/tmp/nonexistent_dir/nonexistent_subdir" + import tempfile + tmpdir = tempfile.mkdtemp() + target = os.path.join(tmpdir, 'nonexistent_subdir') self._callFUT(target, 2, None) - shutil.rmtree("/tmp/nonexistent_dir") + shutil.rmtree(tmpdir) class Test_support_functions(unittest.TestCase): -- cgit v1.2.3 From 136ca148ffec69e54ed0d3c5645e8f7d96413726 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 18 Apr 2012 15:53:07 -0400 Subject: test checkin for automating shiningpanda build from github post-receive url --- CHANGES.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 337754162..7a0a6f28c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,7 +9,6 @@ Bug Fixes return the empty list. This was incorrect, it should have unconditionally returned ``[Everyone]``, and now does. - Features -------- -- cgit v1.2.3 From 2b2451ad920af1defabd8b06509d2100f627dc3f Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 18 Apr 2012 15:56:11 -0400 Subject: test checkin for automating shiningpanda build from github post-receive url (this time for sure) --- CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.txt b/CHANGES.txt index 7a0a6f28c..337754162 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,6 +9,7 @@ Bug Fixes return the empty list. This was incorrect, it should have unconditionally returned ``[Everyone]``, and now does. + Features -------- -- cgit v1.2.3 From 60ea901969e7ea87a68e7ca3da4032724ca90bb7 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 19 Apr 2012 16:43:31 -0400 Subject: take out 'or dotted python name' --- docs/narr/startup.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/narr/startup.rst b/docs/narr/startup.rst index 8e28835af..2a764b0ec 100644 --- a/docs/narr/startup.rst +++ b/docs/narr/startup.rst @@ -42,8 +42,8 @@ Here's a high-level time-ordered overview of what happens when you press ``[pipeline:main]``, or ``[composite:main]`` in the ``.ini`` file. This section represents the configuration of a :term:`WSGI` application that will be served. If you're using a simple application (e.g. - ``[app:main]``), the application :term:`entry point` or :term:`dotted - Python name` will be named on the ``use=`` line within the section's + ``[app:main]``), the application's ``paste.app_factory`` :term:`entry + point` will be named on the ``use=`` line within the section's configuration. If, instead of a simple application, you're using a WSGI :term:`pipeline` (e.g. a ``[pipeline:main]`` section), the application named on the "last" element will refer to your :app:`Pyramid` application. -- cgit v1.2.3 From 0569f999db99e50ffd962eb06d51ec1fb4731181 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 19 Apr 2012 16:45:51 -0400 Subject: squash another reference to dotted name --- docs/narr/startup.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/narr/startup.rst b/docs/narr/startup.rst index 2a764b0ec..f5c741f52 100644 --- a/docs/narr/startup.rst +++ b/docs/narr/startup.rst @@ -59,11 +59,11 @@ Here's a high-level time-ordered overview of what happens when you press system for this application. See :ref:`logging_config` for more information. -#. The application's *constructor* named by the entry point reference or - dotted Python name on the ``use=`` line of the section representing your - :app:`Pyramid` application is passed the key/value parameters mentioned - within the section in which it's defined. The constructor is meant to - return a :term:`router` instance, which is a :term:`WSGI` application. +#. The application's *constructor* named by the entry point reference on the + ``use=`` line of the section representing your :app:`Pyramid` application + is passed the key/value parameters mentioned within the section in which + it's defined. The constructor is meant to return a :term:`router` + instance, which is a :term:`WSGI` application. For :app:`Pyramid` applications, the constructor will be a function named ``main`` in the ``__init__.py`` file within the :term:`package` in which -- cgit v1.2.3 From 7793ec4dfe69462f2db00340a2299a59cd0e73da Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Thu, 19 Apr 2012 18:22:56 -0400 Subject: Change alchemy scaffold README to match the console_scripts setup. --- pyramid/scaffolds/alchemy/README.txt_tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyramid/scaffolds/alchemy/README.txt_tmpl b/pyramid/scaffolds/alchemy/README.txt_tmpl index efea71c5c..9e4aa1125 100644 --- a/pyramid/scaffolds/alchemy/README.txt_tmpl +++ b/pyramid/scaffolds/alchemy/README.txt_tmpl @@ -8,7 +8,7 @@ Getting Started - $venv/bin/python setup.py develop -- $venv/bin/populate_{{project}} development.ini +- $venv/bin/initialize_{{project}}_db development.ini - $venv/bin/pserve development.ini -- cgit v1.2.3 From 90da3b3b1363beb443d190fdcdee8d9323beb64b Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sat, 21 Apr 2012 12:11:59 -0400 Subject: make virtualenv, nose, and coverage testing extras rather than test requirements --- setup.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 29a0f22ca..cbc1075bd 100644 --- a/setup.py +++ b/setup.py @@ -49,16 +49,11 @@ install_requires=[ ] tests_require = [ - 'nose', - 'coverage', 'WebTest >= 1.3.1', # py3 compat - 'virtualenv', ] if not PY3: - tests_require.extend([ - 'zope.component>=3.11.0', - ]) + tests_require.append('zope.component>=3.11.0') docs_extras = [ 'Sphinx', @@ -66,6 +61,12 @@ docs_extras = [ 'repoze.sphinx.autointerface', ] +testing_extras = tests_require + [ + 'nose', + 'coverage', + 'virtualenv', # for scaffolding tests + ] + setup(name='pyramid', version='1.4dev', description=('The Pyramid web application development framework, a ' @@ -95,7 +96,7 @@ setup(name='pyramid', zip_safe=False, install_requires = install_requires, extras_require = { - 'testing':tests_require, + 'testing':testing_extras, 'docs':docs_extras, }, tests_require = tests_require, -- cgit v1.2.3 From f549346f7e524b255c28a25a8de7b5dab8fdce33 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Sat, 21 Apr 2012 21:25:12 -0400 Subject: Use the new Pyramid trove classifiers for the scaffolds. --- pyramid/scaffolds/alchemy/setup.py_tmpl | 2 +- pyramid/scaffolds/starter/setup.py_tmpl | 2 +- pyramid/scaffolds/zodb/setup.py_tmpl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyramid/scaffolds/alchemy/setup.py_tmpl b/pyramid/scaffolds/alchemy/setup.py_tmpl index b80fc52a8..2d8ed028f 100644 --- a/pyramid/scaffolds/alchemy/setup.py_tmpl +++ b/pyramid/scaffolds/alchemy/setup.py_tmpl @@ -22,7 +22,7 @@ setup(name='{{project}}', long_description=README + '\n\n' + CHANGES, classifiers=[ "Programming Language :: Python", - "Framework :: Pylons", + "Framework :: Pyramid", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", ], diff --git a/pyramid/scaffolds/starter/setup.py_tmpl b/pyramid/scaffolds/starter/setup.py_tmpl index 39ac6de9d..58c0a79fc 100644 --- a/pyramid/scaffolds/starter/setup.py_tmpl +++ b/pyramid/scaffolds/starter/setup.py_tmpl @@ -18,7 +18,7 @@ setup(name='{{project}}', long_description=README + '\n\n' + CHANGES, classifiers=[ "Programming Language :: Python", - "Framework :: Pylons", + "Framework :: Pyramid", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", ], diff --git a/pyramid/scaffolds/zodb/setup.py_tmpl b/pyramid/scaffolds/zodb/setup.py_tmpl index 965c0178f..acdf095d5 100644 --- a/pyramid/scaffolds/zodb/setup.py_tmpl +++ b/pyramid/scaffolds/zodb/setup.py_tmpl @@ -21,7 +21,7 @@ setup(name='{{project}}', long_description=README + '\n\n' + CHANGES, classifiers=[ "Programming Language :: Python", - "Framework :: Pylons", + "Framework :: Pyramid", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", ], -- cgit v1.2.3 From ea7a26856e27f4256ec0157635b4c64197f37053 Mon Sep 17 00:00:00 2001 From: VlAleVas Date: Fri, 27 Apr 2012 16:10:13 +0300 Subject: Update docs/narr/urldispatch.rst --- docs/narr/urldispatch.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst index f036ce94e..acbccbdfd 100644 --- a/docs/narr/urldispatch.rst +++ b/docs/narr/urldispatch.rst @@ -547,7 +547,7 @@ add to your application: config.add_route('idea', 'ideas/{idea}') config.add_route('user', 'users/{user}') - config.add_route('tag', 'tags/{tags}') + config.add_route('tag', 'tags/{tag}') config.add_view('mypackage.views.idea_view', route_name='idea') config.add_view('mypackage.views.user_view', route_name='user') -- cgit v1.2.3 From 0e0c83fabc77e2888e26c56df9acda7a5c839530 Mon Sep 17 00:00:00 2001 From: Christopher Lambacher Date: Fri, 27 Apr 2012 11:06:59 -0400 Subject: Don't add a ? to url if query string is empty. --- pyramid/tests/test_url.py | 17 +++++++++++++++++ pyramid/url.py | 8 ++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/pyramid/tests/test_url.py b/pyramid/tests/test_url.py index 0dff1e648..50deb63f3 100644 --- a/pyramid/tests/test_url.py +++ b/pyramid/tests/test_url.py @@ -113,6 +113,14 @@ class TestURLMethodsMixin(unittest.TestCase): self.assertEqual(result, 'http://example.com:5432/context/a?a=hi+there&b=La+Pe%C3%B1a') + def test_resource_url_with_query_empty(self): + request = self._makeOne() + self._registerResourceURL(request.registry) + context = DummyContext() + result = request.resource_url(context, 'a', query=[]) + self.assertEqual(result, + 'http://example.com:5432/context/a') + def test_resource_url_anchor_is_after_root_when_no_elements(self): request = self._makeOne() self._registerResourceURL(request.registry) @@ -334,6 +342,15 @@ class TestURLMethodsMixin(unittest.TestCase): self.assertEqual(result, 'http://example.com:5432/1/2/3?q=1') + def test_route_url_with_empty_query(self): + from pyramid.interfaces import IRoutesMapper + request = self._makeOne() + mapper = DummyRoutesMapper(route=DummyRoute('/1/2/3')) + request.registry.registerUtility(mapper, IRoutesMapper) + result = request.route_url('flub', _query={}) + self.assertEqual(result, + 'http://example.com:5432/1/2/3') + def test_route_url_with_app_url(self): from pyramid.interfaces import IRoutesMapper request = self._makeOne() diff --git a/pyramid/url.py b/pyramid/url.py index 022867967..dd83bb631 100644 --- a/pyramid/url.py +++ b/pyramid/url.py @@ -218,7 +218,9 @@ class URLMethodsMixin(object): port = None if '_query' in kw: - qs = '?' + urlencode(kw.pop('_query'), doseq=True) + query = kw.pop('_query') + if query: + qs = '?' + urlencode(query, doseq=True) if '_anchor' in kw: anchor = kw.pop('_anchor') @@ -494,7 +496,9 @@ class URLMethodsMixin(object): anchor = '' if 'query' in kw: - qs = '?' + urlencode(kw['query'], doseq=True) + query = kw['query'] + if query: + qs = '?' + urlencode(query, doseq=True) if 'anchor' in kw: anchor = kw['anchor'] -- cgit v1.2.3 From fcb209534f069c79ecf90c5499d2955b049aca78 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 27 Apr 2012 11:15:24 -0400 Subject: garden --- CHANGES.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 337754162..b8d42ba6f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,7 +9,6 @@ Bug Fixes return the empty list. This was incorrect, it should have unconditionally returned ``[Everyone]``, and now does. - Features -------- @@ -29,3 +28,9 @@ Features - ``config.set_request_property`` now causes less code to be executed at request construction time. + +- Don't add a ``?`` to URLs generated by request.resource_url if the + ``query`` argument is provided but empty. + +- Don't add a ``?`` to URLs generated by request.route_url if the + ``_query`` argument is provided but empty. -- cgit v1.2.3 From 561a443369bea131fcdbf0476c7e6a4935638d62 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 27 Apr 2012 11:20:08 -0400 Subject: fix example --- CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index b8d42ba6f..67b03d59b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -20,7 +20,7 @@ Features - As of this release, the ``request_method`` predicate, when used, will also imply that ``HEAD`` is implied when you use ``GET``. For example, using ``@view_config(request_method='GET')`` is equivalent to using - ``@view_config(request_method='HEAD')``. Using + ``@view_config(request_method=('GET', 'HEAD'))``. Using ``@view_config(request_method=('GET', 'POST')`` is equivalent to using ``@view_config(request_method=('GET', 'HEAD', 'POST')``. This is because HEAD is a variant of GET that omits the body, and WebOb has special support -- cgit v1.2.3 From 99e617c44d4f55041f2da31c81cff520d403b80a Mon Sep 17 00:00:00 2001 From: Marin Rukavina Date: Fri, 27 Apr 2012 23:52:32 +0200 Subject: Updated static_view to raise HTTP exceptions instead of returning --- pyramid/static.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pyramid/static.py b/pyramid/static.py index dfb602ee0..63ca58597 100644 --- a/pyramid/static.py +++ b/pyramid/static.py @@ -101,17 +101,17 @@ class static_view(object): path = _secure_path(path_tuple) if path is None: - return HTTPNotFound('Out of bounds: %s' % request.url) + raise HTTPNotFound('Out of bounds: %s' % request.url) if self.package_name: # package resource resource_path ='%s/%s' % (self.docroot.rstrip('/'), path) if resource_isdir(self.package_name, resource_path): if not request.path_url.endswith('/'): - return self.add_slash_redirect(request) + self.add_slash_redirect(request) resource_path = '%s/%s' % (resource_path.rstrip('/'),self.index) if not resource_exists(self.package_name, resource_path): - return HTTPNotFound(request.url) + raise HTTPNotFound(request.url) filepath = resource_filename(self.package_name, resource_path) else: # filesystem file @@ -120,10 +120,10 @@ class static_view(object): filepath = normcase(normpath(join(self.norm_docroot, path))) if isdir(filepath): if not request.path_url.endswith('/'): - return self.add_slash_redirect(request) + self.add_slash_redirect(request) filepath = join(filepath, self.index) if not exists(filepath): - return HTTPNotFound(request.url) + raise HTTPNotFound(request.url) return FileResponse(filepath, request, self.cache_max_age) @@ -132,7 +132,7 @@ class static_view(object): qs = request.query_string if qs: url = url + '?' + qs - return HTTPMovedPermanently(url) + raise HTTPMovedPermanently(url) _seps = set(['/', os.sep]) def _contains_slash(item): -- cgit v1.2.3 From 58572aa89dd721f33e90db17a895c920078b8a4c Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Apr 2012 19:11:25 -0700 Subject: Link the first usage of "scaffold" to its definition in the glossary. --- docs/tutorials/wiki/installation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/wiki/installation.rst b/docs/tutorials/wiki/installation.rst index 63b30da5a..d0f476610 100644 --- a/docs/tutorials/wiki/installation.rst +++ b/docs/tutorials/wiki/installation.rst @@ -131,7 +131,7 @@ Make a Project ============== Your next step is to create a project. :app:`Pyramid` supplies a variety of -scaffolds to generate sample projects. For this tutorial, we will use the +:term:`scaffolds` to generate sample projects. For this tutorial, we will use the :term:`ZODB` -oriented scaffold named ``zodb``. The below instructions assume your current working directory is the -- cgit v1.2.3 From 9895440e51c74a46d94a098492f191a3d4b977cb Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Apr 2012 19:31:10 -0700 Subject: expand glossary term for scaffold --- docs/glossary.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/glossary.rst b/docs/glossary.rst index 88598354a..45a79326f 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -922,9 +922,9 @@ Glossary http://docs.pylonsproject.org/projects/pyramid_debugtoolbar/dev/ . scaffold - A project template that helps users get started writing a Pyramid - application quickly. Scaffolds are usually used via the ``pcreate`` - command. + A project template that generates some of the major parts of a Pyramid + application and helps users to quickly get started writing larger + applications. Scaffolds are usually used via the ``pcreate`` command. pyramid_exclog A package which logs Pyramid application exception (error) information -- cgit v1.2.3 From 2bb472b31999b66ff89e9073aa99f2713f68ace3 Mon Sep 17 00:00:00 2001 From: Patricio Paez Date: Sun, 29 Apr 2012 19:29:46 -0500 Subject: Normalize 'Make a project' on both wiki tutorials --- docs/tutorials/wiki/installation.rst | 7 ++++--- docs/tutorials/wiki2/installation.rst | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/tutorials/wiki/installation.rst b/docs/tutorials/wiki/installation.rst index d0f476610..868c99dee 100644 --- a/docs/tutorials/wiki/installation.rst +++ b/docs/tutorials/wiki/installation.rst @@ -130,9 +130,10 @@ Preparation, Windows Make a Project ============== -Your next step is to create a project. :app:`Pyramid` supplies a variety of -:term:`scaffolds` to generate sample projects. For this tutorial, we will use the -:term:`ZODB` -oriented scaffold named ``zodb``. +Your next step is to create a project. For this tutorial, we will use the +:term:`scaffold` named ``zodb``, which generates an application +that uses :term:`ZODB` and :term:`traversal`. :app:`Pyramid` +supplies a variety of scaffolds to generate sample projects. The below instructions assume your current working directory is the "virtualenv" named "pyramidtut". diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index 40486057e..6589a1557 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -67,10 +67,10 @@ Preparation, Windows Making a Project ================ -Your next step is to create a project. :app:`Pyramid` supplies a -variety of scaffolds to generate sample projects. We will use the -``alchemy`` scaffold, which generates an application -that uses :term:`SQLAlchemy` and :term:`URL dispatch`. +Your next step is to create a project. For this tutorial, we will use the +:term:`scaffold` named ``alchemy``, which generates an application +that uses :term:`SQLAlchemy` and :term:`URL dispatch`. :app:`Pyramid` +supplies a variety of scaffolds to generate sample projects. The below instructions assume your current working directory is the "virtualenv" named "pyramidtut". -- cgit v1.2.3 From 39e0d1d2b8e9bc1169c6b2f159fa16d468aaf6c5 Mon Sep 17 00:00:00 2001 From: Dan Jacka Date: Mon, 30 Apr 2012 12:46:44 +1200 Subject: Separator between name and value in --header option to prequest is ':', not '=' --- docs/narr/commandline.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/narr/commandline.rst b/docs/narr/commandline.rst index 886e075e3..1485caefc 100644 --- a/docs/narr/commandline.rst +++ b/docs/narr/commandline.rst @@ -460,7 +460,7 @@ to the console. You can add request header values by using the ``--header`` option:: - $ bin/prequest --header=Host=example.com development.ini / + $ bin/prequest --header=Host:example.com development.ini / Headers are added to the WSGI environment by converting them to their CGI/WSGI equivalents (e.g. ``Host=example.com`` will insert the ``HTTP_HOST`` -- cgit v1.2.3 From b9cead35e09b11c13693d6f6838b70948b568f6c Mon Sep 17 00:00:00 2001 From: Dan Jacka Date: Tue, 1 May 2012 13:33:35 +1200 Subject: Change the example script's description string to match the console_script's name: show_settings --- docs/narr/commandline.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/narr/commandline.rst b/docs/narr/commandline.rst index 1485caefc..4be436836 100644 --- a/docs/narr/commandline.rst +++ b/docs/narr/commandline.rst @@ -718,7 +718,7 @@ we'll pretend you have a distribution with a package in it named def settings_show(): description = """\ Print the deployment settings for a Pyramid application. Example: - 'psettings deployment.ini' + 'show_settings deployment.ini' """ usage = "usage: %prog config_uri" parser = optparse.OptionParser( -- cgit v1.2.3 From 04af145ab4b19d6fe0c4a5087c1722868d6fcedc Mon Sep 17 00:00:00 2001 From: Marin Rukavina Date: Wed, 2 May 2012 02:24:39 +0200 Subject: Fixed up the tests and returned HTTPMovedPermanently --- pyramid/static.py | 6 +-- pyramid/tests/test_static.py | 109 +++++++++++++++++++++++++++++++++---------- 2 files changed, 87 insertions(+), 28 deletions(-) diff --git a/pyramid/static.py b/pyramid/static.py index 63ca58597..50b274dae 100644 --- a/pyramid/static.py +++ b/pyramid/static.py @@ -108,7 +108,7 @@ class static_view(object): resource_path ='%s/%s' % (self.docroot.rstrip('/'), path) if resource_isdir(self.package_name, resource_path): if not request.path_url.endswith('/'): - self.add_slash_redirect(request) + return self.add_slash_redirect(request) resource_path = '%s/%s' % (resource_path.rstrip('/'),self.index) if not resource_exists(self.package_name, resource_path): raise HTTPNotFound(request.url) @@ -120,7 +120,7 @@ class static_view(object): filepath = normcase(normpath(join(self.norm_docroot, path))) if isdir(filepath): if not request.path_url.endswith('/'): - self.add_slash_redirect(request) + return self.add_slash_redirect(request) filepath = join(filepath, self.index) if not exists(filepath): raise HTTPNotFound(request.url) @@ -132,7 +132,7 @@ class static_view(object): qs = request.query_string if qs: url = url + '?' + qs - raise HTTPMovedPermanently(url) + return HTTPMovedPermanently(url) _seps = set(['/', os.sep]) def _contains_slash(item): diff --git a/pyramid/tests/test_static.py b/pyramid/tests/test_static.py index 7f94df990..300647099 100644 --- a/pyramid/tests/test_static.py +++ b/pyramid/tests/test_static.py @@ -70,16 +70,26 @@ class Test_static_view_use_subpath_False(unittest.TestCase): inst = self._makeOne('pyramid.tests:fixtures/static') request = self._makeRequest({'PATH_INFO':'/subdir/../../minimal.pt'}) context = DummyContext() - response = inst(context, request) - self.assertEqual(response.status, '404 Not Found') + from pyramid.httpexceptions import HTTPNotFound + try: + response = inst(context, request) + except HTTPNotFound as e: + self.assertEqual(e.code, 404) + else: + self.assertEqual(response.status, '404 Not Found') def test_oob_dotdotslash_encoded(self): inst = self._makeOne('pyramid.tests:fixtures/static') request = self._makeRequest( {'PATH_INFO':'/subdir/%2E%2E%2F%2E%2E/minimal.pt'}) context = DummyContext() - response = inst(context, request) - self.assertEqual(response.status, '404 Not Found') + from pyramid.httpexceptions import HTTPNotFound + try: + response = inst(context, request) + except HTTPNotFound as e: + self.assertEqual(e.code, 404) + else: + self.assertEqual(response.status, '404 Not Found') def test_oob_os_sep(self): import os @@ -88,15 +98,25 @@ class Test_static_view_use_subpath_False(unittest.TestCase): request = self._makeRequest({'PATH_INFO':'/subdir/%s%sminimal.pt' % (dds, dds)}) context = DummyContext() - response = inst(context, request) - self.assertEqual(response.status, '404 Not Found') + from pyramid.httpexceptions import HTTPNotFound + try: + response = inst(context, request) + except HTTPNotFound as e: + self.assertEqual(e.code, 404) + else: + self.assertEqual(response.status, '404 Not Found') def test_resource_doesnt_exist(self): inst = self._makeOne('pyramid.tests:fixtures/static') request = self._makeRequest({'PATH_INFO':'/notthere'}) context = DummyContext() - response = inst(context, request) - self.assertEqual(response.status, '404 Not Found') + from pyramid.httpexceptions import HTTPNotFound + try: + response = inst(context, request) + except HTTPNotFound as e: + self.assertEqual(e.code, 404) + else: + self.assertEqual(response.status, '404 Not Found') def test_resource_isdir(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -174,8 +194,13 @@ class Test_static_view_use_subpath_False(unittest.TestCase): inst = self._makeOne('pyramid.tests:fixtures/static') request = self._makeRequest({'PATH_INFO':'/notthere.html'}) context = DummyContext() - response = inst(context, request) - self.assertEqual(response.status, '404 Not Found') + from pyramid.httpexceptions import HTTPNotFound + try: + response = inst(context, request) + except HTTPNotFound as e: + self.assertEqual(e.code, 404) + else: + self.assertEqual(response.status, '404 Not Found') def test_resource_with_content_encoding(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -251,33 +276,52 @@ class Test_static_view_use_subpath_True(unittest.TestCase): request = self._makeRequest() request.subpath = ('.', 'index.html') context = DummyContext() - response = inst(context, request) - self.assertEqual(response.status, '404 Not Found') + from pyramid.httpexceptions import HTTPNotFound + try: + response = inst(context, request) + except HTTPNotFound as e: + self.assertEqual(e.code, 404) + else: + self.assertEqual(response.status, '404 Not Found') def test_oob_emptyelement(self): inst = self._makeOne('pyramid.tests:fixtures/static') request = self._makeRequest() request.subpath = ('', 'index.html') context = DummyContext() - response = inst(context, request) - self.assertEqual(response.status, '404 Not Found') + from pyramid.httpexceptions import HTTPNotFound + try: + response = inst(context, request) + except HTTPNotFound as e: + self.assertEqual(e.code, 404) + else: + self.assertEqual(response.status, '404 Not Found') def test_oob_dotdotslash(self): inst = self._makeOne('pyramid.tests:fixtures/static') request = self._makeRequest() request.subpath = ('subdir', '..', '..', 'minimal.pt') context = DummyContext() - response = inst(context, request) - self.assertEqual(response.status, '404 Not Found') + from pyramid.httpexceptions import HTTPNotFound + try: + response = inst(context, request) + except HTTPNotFound as e: + self.assertEqual(e.code, 404) + else: + self.assertEqual(response.status, '404 Not Found') def test_oob_dotdotslash_encoded(self): inst = self._makeOne('pyramid.tests:fixtures/static') request = self._makeRequest() request.subpath = ('subdir', '%2E%2E', '%2E%2E', 'minimal.pt') context = DummyContext() - response = inst(context, request) - self.assertEqual(response.status, '404 Not Found') - + from pyramid.httpexceptions import HTTPNotFound + try: + response = inst(context, request) + except HTTPNotFound as e: + self.assertEqual(e.code, 404) + else: + self.assertEqual(response.status, '404 Not Found') def test_oob_os_sep(self): import os inst = self._makeOne('pyramid.tests:fixtures/static') @@ -285,16 +329,26 @@ class Test_static_view_use_subpath_True(unittest.TestCase): request = self._makeRequest() request.subpath = ('subdir', dds, dds, 'minimal.pt') context = DummyContext() - response = inst(context, request) - self.assertEqual(response.status, '404 Not Found') + from pyramid.httpexceptions import HTTPNotFound + try: + response = inst(context, request) + except HTTPNotFound as e: + self.assertEqual(e.code, 404) + else: + self.assertEqual(response.status, '404 Not Found') def test_resource_doesnt_exist(self): inst = self._makeOne('pyramid.tests:fixtures/static') request = self._makeRequest() request.subpath = ('notthere,') context = DummyContext() - response = inst(context, request) - self.assertEqual(response.status, '404 Not Found') + from pyramid.httpexceptions import HTTPNotFound + try: + response = inst(context, request) + except HTTPNotFound as e: + self.assertEqual(e.code, 404) + else: + self.assertEqual(response.status, '404 Not Found') def test_resource_isdir(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -361,8 +415,13 @@ class Test_static_view_use_subpath_True(unittest.TestCase): request = self._makeRequest() request.subpath = ('notthere.html',) context = DummyContext() - response = inst(context, request) - self.assertEqual(response.status, '404 Not Found') + from pyramid.httpexceptions import HTTPNotFound + try: + response = inst(context, request) + except HTTPNotFound as e: + self.assertEqual(e.code, 404) + else: + self.assertEqual(response.status, '404 Not Found') class DummyContext: pass -- cgit v1.2.3 From 3d65afea0d2bd529a87f72d87a986c989ebffd29 Mon Sep 17 00:00:00 2001 From: Marin Rukavina Date: Wed, 2 May 2012 02:55:03 +0200 Subject: Updated tests for static files and made static.py raise all HTTP exceptions --- pyramid/static.py | 6 +++--- pyramid/tests/test_static.py | 32 ++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/pyramid/static.py b/pyramid/static.py index 50b274dae..63ca58597 100644 --- a/pyramid/static.py +++ b/pyramid/static.py @@ -108,7 +108,7 @@ class static_view(object): resource_path ='%s/%s' % (self.docroot.rstrip('/'), path) if resource_isdir(self.package_name, resource_path): if not request.path_url.endswith('/'): - return self.add_slash_redirect(request) + self.add_slash_redirect(request) resource_path = '%s/%s' % (resource_path.rstrip('/'),self.index) if not resource_exists(self.package_name, resource_path): raise HTTPNotFound(request.url) @@ -120,7 +120,7 @@ class static_view(object): filepath = normcase(normpath(join(self.norm_docroot, path))) if isdir(filepath): if not request.path_url.endswith('/'): - return self.add_slash_redirect(request) + self.add_slash_redirect(request) filepath = join(filepath, self.index) if not exists(filepath): raise HTTPNotFound(request.url) @@ -132,7 +132,7 @@ class static_view(object): qs = request.query_string if qs: url = url + '?' + qs - return HTTPMovedPermanently(url) + raise HTTPMovedPermanently(url) _seps = set(['/', os.sep]) def _contains_slash(item): diff --git a/pyramid/tests/test_static.py b/pyramid/tests/test_static.py index 300647099..0141405e9 100644 --- a/pyramid/tests/test_static.py +++ b/pyramid/tests/test_static.py @@ -38,11 +38,17 @@ class Test_static_view_use_subpath_False(unittest.TestCase): inst = self._makeOne('pyramid.tests:fixtures/static') request = self._makeRequest({'PATH_INFO':''}) context = DummyContext() - response = inst(context, request) - response.prepare(request.environ) - self.assertEqual(response.status, '301 Moved Permanently') - self.assertTrue(b'http://example.com:6543/' in response.body) - + from pyramid.httpexceptions import HTTPMovedPermanently + try: + response = inst(context, request) + except HTTPMovedPermanently as e: + self.assertEqual(e.code, 301) + self.assertTrue(b'http://example.com:6543/' in e.location) + else: + response.prepare(request.environ) + self.assertEqual(response.status, '301 Moved Permanently') + self.assertTrue(b'http://example.com:6543/' in response.body) + def test_path_info_slash_means_index_html(self): inst = self._makeOne('pyramid.tests:fixtures/static') request = self._makeRequest() @@ -258,11 +264,17 @@ class Test_static_view_use_subpath_True(unittest.TestCase): request = self._makeRequest({'PATH_INFO':''}) request.subpath = () context = DummyContext() - response = inst(context, request) - response.prepare(request.environ) - self.assertEqual(response.status, '301 Moved Permanently') - self.assertTrue(b'http://example.com:6543/' in response.body) - + from pyramid.httpexceptions import HTTPMovedPermanently + try: + response = inst(context, request) + except HTTPMovedPermanently as e: + self.assertEqual(e.code, 301) + self.assertTrue(b'http://example.com:6543/' in e.location) + else: + response.prepare(request.environ) + self.assertEqual(response.status, '301 Moved Permanently') + self.assertTrue(b'http://example.com:6543/' in response.body) + def test_path_info_slash_means_index_html(self): inst = self._makeOne('pyramid.tests:fixtures/static') request = self._makeRequest() -- cgit v1.2.3 From e7c4dd632daa71f72bd5e7b6824621cad0dac7cc Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 2 May 2012 23:14:25 -0400 Subject: simplify tests --- pyramid/tests/test_static.py | 105 +++++++------------------------------------ 1 file changed, 15 insertions(+), 90 deletions(-) diff --git a/pyramid/tests/test_static.py b/pyramid/tests/test_static.py index 0141405e9..94497d4f6 100644 --- a/pyramid/tests/test_static.py +++ b/pyramid/tests/test_static.py @@ -39,15 +39,7 @@ class Test_static_view_use_subpath_False(unittest.TestCase): request = self._makeRequest({'PATH_INFO':''}) context = DummyContext() from pyramid.httpexceptions import HTTPMovedPermanently - try: - response = inst(context, request) - except HTTPMovedPermanently as e: - self.assertEqual(e.code, 301) - self.assertTrue(b'http://example.com:6543/' in e.location) - else: - response.prepare(request.environ) - self.assertEqual(response.status, '301 Moved Permanently') - self.assertTrue(b'http://example.com:6543/' in response.body) + self.assertRaises(HTTPMovedPermanently, inst, context, request) def test_path_info_slash_means_index_html(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -77,12 +69,7 @@ class Test_static_view_use_subpath_False(unittest.TestCase): request = self._makeRequest({'PATH_INFO':'/subdir/../../minimal.pt'}) context = DummyContext() from pyramid.httpexceptions import HTTPNotFound - try: - response = inst(context, request) - except HTTPNotFound as e: - self.assertEqual(e.code, 404) - else: - self.assertEqual(response.status, '404 Not Found') + self.assertRaises(HTTPNotFound, inst, context, request) def test_oob_dotdotslash_encoded(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -90,12 +77,7 @@ class Test_static_view_use_subpath_False(unittest.TestCase): {'PATH_INFO':'/subdir/%2E%2E%2F%2E%2E/minimal.pt'}) context = DummyContext() from pyramid.httpexceptions import HTTPNotFound - try: - response = inst(context, request) - except HTTPNotFound as e: - self.assertEqual(e.code, 404) - else: - self.assertEqual(response.status, '404 Not Found') + self.assertRaises(HTTPNotFound, inst, context, request) def test_oob_os_sep(self): import os @@ -105,24 +87,14 @@ class Test_static_view_use_subpath_False(unittest.TestCase): (dds, dds)}) context = DummyContext() from pyramid.httpexceptions import HTTPNotFound - try: - response = inst(context, request) - except HTTPNotFound as e: - self.assertEqual(e.code, 404) - else: - self.assertEqual(response.status, '404 Not Found') + self.assertRaises(HTTPNotFound, inst, context, request) def test_resource_doesnt_exist(self): inst = self._makeOne('pyramid.tests:fixtures/static') request = self._makeRequest({'PATH_INFO':'/notthere'}) context = DummyContext() from pyramid.httpexceptions import HTTPNotFound - try: - response = inst(context, request) - except HTTPNotFound as e: - self.assertEqual(e.code, 404) - else: - self.assertEqual(response.status, '404 Not Found') + self.assertRaises(HTTPNotFound, inst, context, request) def test_resource_isdir(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -201,12 +173,7 @@ class Test_static_view_use_subpath_False(unittest.TestCase): request = self._makeRequest({'PATH_INFO':'/notthere.html'}) context = DummyContext() from pyramid.httpexceptions import HTTPNotFound - try: - response = inst(context, request) - except HTTPNotFound as e: - self.assertEqual(e.code, 404) - else: - self.assertEqual(response.status, '404 Not Found') + self.assertRaises(HTTPNotFound, inst, context, request) def test_resource_with_content_encoding(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -265,15 +232,7 @@ class Test_static_view_use_subpath_True(unittest.TestCase): request.subpath = () context = DummyContext() from pyramid.httpexceptions import HTTPMovedPermanently - try: - response = inst(context, request) - except HTTPMovedPermanently as e: - self.assertEqual(e.code, 301) - self.assertTrue(b'http://example.com:6543/' in e.location) - else: - response.prepare(request.environ) - self.assertEqual(response.status, '301 Moved Permanently') - self.assertTrue(b'http://example.com:6543/' in response.body) + self.assertRaises(HTTPMovedPermanently, inst, context, request) def test_path_info_slash_means_index_html(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -289,12 +248,7 @@ class Test_static_view_use_subpath_True(unittest.TestCase): request.subpath = ('.', 'index.html') context = DummyContext() from pyramid.httpexceptions import HTTPNotFound - try: - response = inst(context, request) - except HTTPNotFound as e: - self.assertEqual(e.code, 404) - else: - self.assertEqual(response.status, '404 Not Found') + self.assertRaises(HTTPNotFound, inst, context, request) def test_oob_emptyelement(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -302,12 +256,7 @@ class Test_static_view_use_subpath_True(unittest.TestCase): request.subpath = ('', 'index.html') context = DummyContext() from pyramid.httpexceptions import HTTPNotFound - try: - response = inst(context, request) - except HTTPNotFound as e: - self.assertEqual(e.code, 404) - else: - self.assertEqual(response.status, '404 Not Found') + self.assertRaises(HTTPNotFound, inst, context, request) def test_oob_dotdotslash(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -315,12 +264,7 @@ class Test_static_view_use_subpath_True(unittest.TestCase): request.subpath = ('subdir', '..', '..', 'minimal.pt') context = DummyContext() from pyramid.httpexceptions import HTTPNotFound - try: - response = inst(context, request) - except HTTPNotFound as e: - self.assertEqual(e.code, 404) - else: - self.assertEqual(response.status, '404 Not Found') + self.assertRaises(HTTPNotFound, inst, context, request) def test_oob_dotdotslash_encoded(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -328,12 +272,8 @@ class Test_static_view_use_subpath_True(unittest.TestCase): request.subpath = ('subdir', '%2E%2E', '%2E%2E', 'minimal.pt') context = DummyContext() from pyramid.httpexceptions import HTTPNotFound - try: - response = inst(context, request) - except HTTPNotFound as e: - self.assertEqual(e.code, 404) - else: - self.assertEqual(response.status, '404 Not Found') + self.assertRaises(HTTPNotFound, inst, context, request) + def test_oob_os_sep(self): import os inst = self._makeOne('pyramid.tests:fixtures/static') @@ -342,12 +282,7 @@ class Test_static_view_use_subpath_True(unittest.TestCase): request.subpath = ('subdir', dds, dds, 'minimal.pt') context = DummyContext() from pyramid.httpexceptions import HTTPNotFound - try: - response = inst(context, request) - except HTTPNotFound as e: - self.assertEqual(e.code, 404) - else: - self.assertEqual(response.status, '404 Not Found') + self.assertRaises(HTTPNotFound, inst, context, request) def test_resource_doesnt_exist(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -355,12 +290,7 @@ class Test_static_view_use_subpath_True(unittest.TestCase): request.subpath = ('notthere,') context = DummyContext() from pyramid.httpexceptions import HTTPNotFound - try: - response = inst(context, request) - except HTTPNotFound as e: - self.assertEqual(e.code, 404) - else: - self.assertEqual(response.status, '404 Not Found') + self.assertRaises(HTTPNotFound, inst, context, request) def test_resource_isdir(self): inst = self._makeOne('pyramid.tests:fixtures/static') @@ -428,12 +358,7 @@ class Test_static_view_use_subpath_True(unittest.TestCase): request.subpath = ('notthere.html',) context = DummyContext() from pyramid.httpexceptions import HTTPNotFound - try: - response = inst(context, request) - except HTTPNotFound as e: - self.assertEqual(e.code, 404) - else: - self.assertEqual(response.status, '404 Not Found') + self.assertRaises(HTTPNotFound, inst, context, request) class DummyContext: pass -- cgit v1.2.3 From 988035afbb745237ea8bec0a7c5e4552d2fc98ba Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 2 May 2012 23:15:46 -0400 Subject: add a change note --- CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 67b03d59b..34d60090d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -34,3 +34,7 @@ Features - Don't add a ``?`` to URLs generated by request.route_url if the ``_query`` argument is provided but empty. + +- The static view machinery now raises (rather than returns) ``HTTPNotFound`` + and ``HTTPMovedPermanently`` exceptions, so these can be caught by the + NotFound view (and other exception views). -- cgit v1.2.3 From 004882434aa166a58c3b2148322e08ce61ec4cb7 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 2 May 2012 23:39:54 -0400 Subject: garden --- TODO.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/TODO.txt b/TODO.txt index e0fb0fa27..4b4f48499 100644 --- a/TODO.txt +++ b/TODO.txt @@ -4,6 +4,10 @@ Pyramid TODOs Nice-to-Have ------------ +- config.set_registry_attr (with conflict detection). + +- _fix_registry should dictify the registry being fixed. + - Provide the presumed renderer name to the called view as an attribute of the request. @@ -67,8 +71,6 @@ Nice-to-Have app1" and "domain app1.localhost = app1"), ProxyPreserveHost and the nginx equivalent, preserving HTTPS URLs. -- _fix_registry should dictify the registry being fixed. - - Make "localizer" a property of request (instead of requiring "get_localizer(request)"? @@ -126,6 +128,9 @@ Future - 1.5: Remove ``pyramid.requests.DeprecatedRequestMethodsMixin``. +- 1.5: Maybe? deprecate set_request_property in favor of pointing people at + set_request_method. + - 1.6: Remove IContextURL and TraversalContextURL. Probably Bad Ideas -- cgit v1.2.3