diff options
| author | Chris McDonough <chrism@plope.com> | 2018-04-24 06:59:45 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2018-04-24 06:59:45 -0400 |
| commit | 50efc321cb14d76433216783c11b9eb99a7d44c8 (patch) | |
| tree | f052e84e9b6753d4c4ef167311ea3118524809b5 | |
| parent | f9c30f5009ccbea2d17c4109e838862b41531623 (diff) | |
| parent | 5fce6fd72960ed0893b1d77c8db9efd64a5a81ab (diff) | |
| download | pyramid-50efc321cb14d76433216783c11b9eb99a7d44c8.tar.gz pyramid-50efc321cb14d76433216783c11b9eb99a7d44c8.tar.bz2 pyramid-50efc321cb14d76433216783c11b9eb99a7d44c8.zip | |
Merge branch 'master' of github.com:Pylons/pyramid
| -rw-r--r-- | HACKING.txt | 2 | ||||
| -rw-r--r-- | RELEASING.txt | 2 | ||||
| -rw-r--r-- | docs/glossary.rst | 12 | ||||
| -rw-r--r-- | docs/narr/project.rst | 2 | ||||
| -rw-r--r-- | docs/narr/sessions.rst | 6 | ||||
| -rw-r--r-- | docs/quick_tutorial/authentication.rst | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki/authorization.rst | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki/basiclayout.rst | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki/distributing.rst | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki2/definingmodels.rst | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki2/distributing.rst | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki2/installation.rst | 2 | ||||
| -rw-r--r-- | pyramid/scripting.py | 19 | ||||
| -rw-r--r-- | pyramid/tests/test_scripting.py | 43 | ||||
| -rw-r--r-- | pyramid/url.py | 46 | ||||
| -rw-r--r-- | setup.py | 6 | ||||
| -rw-r--r-- | tox.ini | 2 |
17 files changed, 69 insertions, 85 deletions
diff --git a/HACKING.txt b/HACKING.txt index ad89fc490..20cff7cac 100644 --- a/HACKING.txt +++ b/HACKING.txt @@ -161,7 +161,7 @@ Running Tests $ $VENV/bin/nosetests pyramid.tests.test_module:ClassName Optionally you can install a nose plugin, `nose-selecttests - <https://pypi.python.org/pypi/nose-selecttests/>`_, and use a regular + <https://pypi.org/project/nose-selecttests/>`_, and use a regular expression with the ``-t`` parameter to run tests. # run a single test diff --git a/RELEASING.txt b/RELEASING.txt index f38903985..ba978562e 100644 --- a/RELEASING.txt +++ b/RELEASING.txt @@ -139,7 +139,7 @@ Marketing and communications Pyramid 1.x released. PyPI -https://pypi.python.org/pypi/pyramid/1.x +https://pypi.org/project/pyramid/1.x/ === One time only for new version, first pre-release === What's New diff --git a/docs/glossary.rst b/docs/glossary.rst index 7f1147fa1..7e16b569e 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -332,7 +332,7 @@ Glossary for middleware exist, such as caching, content-transport encoding, and other functions. See `WSGI documentation <https://wsgi.readthedocs.io/en/latest/>`_ or `PyPI - <https://pypi.python.org/pypi>`_ to find middleware for your application. + <https://pypi.org/>`_ to find middleware for your application. pipeline The :term:`PasteDeploy` term for a single configuration of a WSGI @@ -394,7 +394,7 @@ Glossary between templates. Genshi - An `XML templating language <https://pypi.python.org/pypi/Genshi/>`_ + An `XML templating language <https://pypi.org/project/Genshi/>`_ by Christopher Lenz. Jinja2 @@ -449,7 +449,7 @@ Glossary subpath. See :ref:`star_subpath` for more information. interface - A `Zope interface <https://pypi.python.org/pypi/zope.interface>`_ + A `Zope interface <https://pypi.org/project/zope.interface/>`_ object. In :app:`Pyramid`, an interface may be attached to a :term:`resource` object or a :term:`request` object in order to identify that the object is "of a type". Interfaces are used @@ -495,7 +495,7 @@ Glossary repoze.catalog An indexing and search facility (fielded and full-text) based on - `zope.index <https://pypi.python.org/pypi/zope.index>`_. See `the + `zope.index <https://pypi.org/project/zope.index/>`_. See `the documentation <http://docs.repoze.org/catalog>`_ for more information. @@ -707,7 +707,7 @@ Glossary :ref:`multidict_narr` and :class:`pyramid.interfaces.IMultiDict`. PyPI - `The Python Package Index <https://pypi.python.org/pypi>`_, a collection + `The Python Package Index <https://pypi.org/>`_, a collection of software available for Python. Agendaless Consulting @@ -1100,7 +1100,7 @@ Glossary pyramid_redis_sessions A package by Eric Rasmussen which allows you to store Pyramid session data in a Redis database. See - https://pypi.python.org/pypi/pyramid_redis_sessions for more information. + https://pypi.org/project/pyramid_redis_sessions/ for more information. cache busting A technique used when serving a cacheable static asset in order to force diff --git a/docs/narr/project.rst b/docs/narr/project.rst index c54e28137..5234d89d1 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -763,7 +763,7 @@ field. The version number is specified in the ``version`` value. A short description is provided in the ``description`` field. The ``long_description`` is conventionally the content of the ``README`` and ``CHANGES`` files appended together. The ``classifiers`` field is a list of `Trove classifiers -<https://pypi.python.org/pypi?%3Aaction=list_classifiers>`_ describing your +<https://pypi.org/pypi?%3Aaction=list_classifiers>`_ describing your application. ``author`` and ``author_email`` are text fields which probably don't need any description. ``url`` is a field that should point at your application project's URL (if any). ``packages=find_packages()`` causes all diff --git a/docs/narr/sessions.rst b/docs/narr/sessions.rst index b34d7a4f1..c0354841c 100644 --- a/docs/narr/sessions.rst +++ b/docs/narr/sessions.rst @@ -170,13 +170,13 @@ pyramid_beaker_ Beaker_ Session factory for Pyramid sessioning system. ======================= ======= ============================= -.. _pyramid_nacl_session: https://pypi.python.org/pypi/pyramid_nacl_session +.. _pyramid_nacl_session: https://pypi.org/project/pyramid_nacl_session/ .. _PyNaCl: https://pynacl.readthedocs.io/en/latest/secret/ -.. _pyramid_redis_sessions: https://pypi.python.org/pypi/pyramid_redis_sessions +.. _pyramid_redis_sessions: https://pypi.org/project/pyramid_redis_sessions/ .. _Redis: https://redis.io/ -.. _pyramid_beaker: https://pypi.python.org/pypi/pyramid_beaker +.. _pyramid_beaker: https://pypi.org/project/pyramid_beaker/ .. _Beaker: https://beaker.readthedocs.io/en/latest/ .. index:: diff --git a/docs/quick_tutorial/authentication.rst b/docs/quick_tutorial/authentication.rst index 684cce6a6..95acc33e4 100644 --- a/docs/quick_tutorial/authentication.rst +++ b/docs/quick_tutorial/authentication.rst @@ -152,4 +152,4 @@ Extra credit .. seealso:: See also :ref:`security_chapter`, :ref:`AuthTktAuthenticationPolicy <authentication_module>`, `bcrypt - <https://pypi.python.org/pypi/bcrypt>`_ + <https://pypi.org/project/bcrypt/>`_ diff --git a/docs/tutorials/wiki/authorization.rst b/docs/tutorials/wiki/authorization.rst index 9a8313748..a2e61e632 100644 --- a/docs/tutorials/wiki/authorization.rst +++ b/docs/tutorials/wiki/authorization.rst @@ -43,7 +43,7 @@ Access control Add dependencies ~~~~~~~~~~~~~~~~ -Just like in :ref:`wiki_defining_views`, we need a new dependency. We need to add the `bcrypt <https://pypi.python.org/pypi/bcrypt>`_ package, to our tutorial package's ``setup.py`` file by assigning this dependency to the ``requires`` parameter in the ``setup()`` function. +Just like in :ref:`wiki_defining_views`, we need a new dependency. We need to add the `bcrypt <https://pypi.org/project/bcrypt/>`_ package, to our tutorial package's ``setup.py`` file by assigning this dependency to the ``requires`` parameter in the ``setup()`` function. Open ``setup.py`` and edit it to look like the following: diff --git a/docs/tutorials/wiki/basiclayout.rst b/docs/tutorials/wiki/basiclayout.rst index b6363088b..a0b365a23 100644 --- a/docs/tutorials/wiki/basiclayout.rst +++ b/docs/tutorials/wiki/basiclayout.rst @@ -44,7 +44,7 @@ Open ``tutorial/__init__.py``. It should already contain the following: #. *Line 16*. Include support for the :term:`Chameleon` template rendering bindings, allowing us to use the ``.pt`` templates. -#. *Line 17*. Include support for ``pyramid_tm``, allowing Pyramid requests to join the active transaction as provided by the `transaction <https://pypi.python.org/pypi/transaction>`_ package. +#. *Line 17*. Include support for ``pyramid_tm``, allowing Pyramid requests to join the active transaction as provided by the `transaction <https://pypi.org/project/transaction/>`_ package. #. *Line 18*. Include support for ``pyramid_retry`` to retry a request when transient exceptions occur. diff --git a/docs/tutorials/wiki/distributing.rst b/docs/tutorials/wiki/distributing.rst index fb0a552e0..011a94f51 100644 --- a/docs/tutorials/wiki/distributing.rst +++ b/docs/tutorials/wiki/distributing.rst @@ -35,6 +35,6 @@ Note that this command creates a tarball in the "dist" subdirectory named ``tutorial-0.0.tar.gz``. You can send this file to your friends to show them your cool new application. They should be able to install it by pointing the ``pip install`` command directly at it. Or you can upload it to `PyPI -<https://pypi.python.org/pypi>`_ and share it with the rest of the world, where +<https://pypi.org/>`_ and share it with the rest of the world, where it can be downloaded via ``pip install`` remotely like any other package people download from PyPI. diff --git a/docs/tutorials/wiki2/definingmodels.rst b/docs/tutorials/wiki2/definingmodels.rst index 5cebb943c..fd1967d99 100644 --- a/docs/tutorials/wiki2/definingmodels.rst +++ b/docs/tutorials/wiki2/definingmodels.rst @@ -25,7 +25,7 @@ dependency of the original "tutorial" application. The original "tutorial" application was generated by the cookiecutter; it doesn't know about our custom application requirements. -We need to add a dependency, the `bcrypt <https://pypi.python.org/pypi/bcrypt>`_ package, to our ``tutorial`` +We need to add a dependency, the `bcrypt <https://pypi.org/project/bcrypt/>`_ package, to our ``tutorial`` package's ``setup.py`` file by assigning this dependency to the ``requires`` parameter in the ``setup()`` function. diff --git a/docs/tutorials/wiki2/distributing.rst b/docs/tutorials/wiki2/distributing.rst index dd6b1b750..d296363ed 100644 --- a/docs/tutorials/wiki2/distributing.rst +++ b/docs/tutorials/wiki2/distributing.rst @@ -35,6 +35,6 @@ Note that this command creates a tarball in the ``dist`` subdirectory named ``tutorial-0.0.tar.gz``. You can send this file to your friends to show them your cool new application. They should be able to install it by pointing the ``pip install`` command directly at it. Or you can upload it to `PyPI -<https://pypi.python.org/pypi>`_ and share it with the rest of the world, where +<https://pypi.org/>`_ and share it with the rest of the world, where it can be downloaded via ``pip install`` remotely like any other package people download from PyPI. diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index 7076d03bf..5a935f7fc 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -468,7 +468,7 @@ assumptions: https://docs.pylonsproject.org/projects/pyramid-tm/en/latest/ .. _zope.sqlalchemy: - https://pypi.python.org/pypi/zope.sqlalchemy + https://pypi.org/project/zope.sqlalchemy/ .. _transaction: https://zodb.readthedocs.io/en/latest/transactions.html diff --git a/pyramid/scripting.py b/pyramid/scripting.py index 7607d3ea3..087b55ccb 100644 --- a/pyramid/scripting.py +++ b/pyramid/scripting.py @@ -8,7 +8,7 @@ from pyramid.interfaces import ( from pyramid.request import Request from pyramid.request import apply_request_extensions -from pyramid.threadlocal import manager as threadlocal_manager +from pyramid.threadlocal import RequestContext from pyramid.traversal import DefaultRootFactory def get_root(app, request=None): @@ -26,10 +26,11 @@ def get_root(app, request=None): registry = app.registry if request is None: request = _make_request('/', registry) - threadlocals = {'registry':registry, 'request':request} - app.threadlocal_manager.push(threadlocals) - def closer(request=request): # keep request alive via this function default - app.threadlocal_manager.pop() + request.registry = registry + ctx = RequestContext(request) + ctx.begin() + def closer(): + ctx.end() root = app.root_factory(request) return root, closer @@ -87,12 +88,12 @@ def prepare(request=None, registry=None): # NB: even though _make_request might have already set registry on # request, we reset it in case someone has passed in their own # request. - request.registry = registry - threadlocals = {'registry':registry, 'request':request} - threadlocal_manager.push(threadlocals) + request.registry = registry + ctx = RequestContext(request) + ctx.begin() apply_request_extensions(request) def closer(): - threadlocal_manager.pop() + ctx.end() root_factory = registry.queryUtility(IRootFactory, default=DefaultRootFactory) root = root_factory(request) diff --git a/pyramid/tests/test_scripting.py b/pyramid/tests/test_scripting.py index 00f738e02..ed88bb470 100644 --- a/pyramid/tests/test_scripting.py +++ b/pyramid/tests/test_scripting.py @@ -8,38 +8,35 @@ class Test_get_root(unittest.TestCase): def _makeRegistry(self): return DummyRegistry([DummyFactory]) + def setUp(self): + from pyramid.threadlocal import manager + self.manager = manager + self.default = manager.get() + def test_it_norequest(self): registry = self._makeRegistry() app = DummyApp(registry=registry) root, closer = self._callFUT(app) - self.assertEqual(len(app.threadlocal_manager.pushed), 1) - pushed = app.threadlocal_manager.pushed[0] + self.assertEqual(dummy_root, root) + pushed = self.manager.get() self.assertEqual(pushed['registry'], registry) - self.assertEqual(pushed['request'].registry, app.registry) - self.assertEqual(len(app.threadlocal_manager.popped), 0) + self.assertEqual(pushed['request'].registry, registry) + self.assertEqual(pushed['request'].environ['path'], '/') closer() - self.assertEqual(len(app.threadlocal_manager.popped), 1) + self.assertEqual(self.default, self.manager.get()) def test_it_withrequest(self): registry = self._makeRegistry() app = DummyApp(registry=registry) request = DummyRequest({}) root, closer = self._callFUT(app, request) - self.assertEqual(len(app.threadlocal_manager.pushed), 1) - pushed = app.threadlocal_manager.pushed[0] + self.assertEqual(dummy_root, root) + pushed = self.manager.get() self.assertEqual(pushed['registry'], registry) self.assertEqual(pushed['request'], request) - self.assertEqual(len(app.threadlocal_manager.popped), 0) + self.assertEqual(pushed['request'].registry, registry) closer() - self.assertEqual(len(app.threadlocal_manager.popped), 1) - - def test_it_requestfactory_overridden(self): - registry = self._makeRegistry() - app = DummyApp(registry=registry) - root, closer = self._callFUT(app) - self.assertEqual(len(app.threadlocal_manager.pushed), 1) - pushed = app.threadlocal_manager.pushed[0] - self.assertEqual(pushed['request'].environ['path'], '/') + self.assertEqual(self.default, self.manager.get()) class Test_prepare(unittest.TestCase): def _callFUT(self, request=None, registry=None): @@ -206,24 +203,12 @@ class DummyRegistry(object): class DummyApp: def __init__(self, registry=None): - self.threadlocal_manager = DummyThreadLocalManager() if registry: self.registry = registry def root_factory(self, environ): return dummy_root -class DummyThreadLocalManager: - def __init__(self): - self.pushed = [] - self.popped = [] - - def push(self, item): - self.pushed.append(item) - - def pop(self): - self.popped.append(True) - class DummyRequest(object): matchdict = None matched_route = None diff --git a/pyramid/url.py b/pyramid/url.py index d4b44ef23..852aa5e55 100644 --- a/pyramid/url.py +++ b/pyramid/url.py @@ -161,15 +161,14 @@ class URLMethodsMixin(object): ``*remainder`` replacement value, it is tacked on to the URL after being URL-quoted-except-for-embedded-slashes. - If no ``_query`` keyword argument is provided, the request query string - will be returned in the URL. If it is present, it will be used to - compose a query string that will be tacked on to the end of the URL, - replacing any request query string. The value of ``_query`` may be a - sequence of two-tuples *or* a data structure with an ``.items()`` - method that returns a sequence of two-tuples (presumably a dictionary). - This data structure will be turned into a query string per the - documentation of :func:`pyramid.url.urlencode` function. This will - produce a query string in the ``x-www-form-urlencoded`` format. A + If ``_query`` is provided, it will be used to compose a query string + that will be tacked on to the end of the URL. The value of ``_query`` + may be a sequence of two-tuples *or* a data structure with an + ``.items()`` method that returns a sequence of two-tuples + (presumably a dictionary). This data structure will be turned into + a query string per the documentation of the + :func:`pyramid.url.urlencode` function. This will produce a query + string in the ``x-www-form-urlencoded`` format. A non-``x-www-form-urlencoded`` query string may be used by passing a *string* value as ``_query`` in which case it will be URL-quoted (e.g. query="foo bar" will become "foo%20bar"). However, the result @@ -353,20 +352,21 @@ class URLMethodsMixin(object): ``elements`` are used, the generated URL will *not* end in a trailing slash. - If a keyword argument ``query`` is present, it will be used to compose - a query string that will be tacked on to the end of the URL. The value - of ``query`` may be a sequence of two-tuples *or* a data structure with - an ``.items()`` method that returns a sequence of two-tuples - (presumably a dictionary). This data structure will be turned into a - query string per the documentation of :func:`pyramid.url.urlencode` - function. This will produce a query string in the - ``x-www-form-urlencoded`` encoding. A non-``x-www-form-urlencoded`` - query string may be used by passing a *string* value as ``query`` in - which case it will be URL-quoted (e.g. query="foo bar" will become - "foo%20bar"). However, the result will not need to be in ``k=v`` form - as required by ``x-www-form-urlencoded``. After the query data is - turned into a query string, a leading ``?`` is prepended, and the - resulting string is appended to the generated URL. + If ``query`` is provided, it will be used to compose a query string + that will be tacked on to the end of the URL. The value of ``query`` + may be a sequence of two-tuples *or* a data structure with an + ``.items()`` method that returns a sequence of two-tuples + (presumably a dictionary). This data structure will be turned into + a query string per the documentation of the + :func:`pyramid.url.urlencode` function. This will produce a query + string in the ``x-www-form-urlencoded`` format. A + non-``x-www-form-urlencoded`` query string may be used by passing a + *string* value as ``query`` in which case it will be URL-quoted + (e.g. query="foo bar" will become "foo%20bar"). However, the result + will not need to be in ``k=v`` form as required by + ``x-www-form-urlencoded``. After the query data is turned into a query + string, a leading ``?`` is prepended, and the resulting string is + appended to the generated URL. .. note:: @@ -22,10 +22,10 @@ CHANGES = readfile('CHANGES.rst') install_requires = [ 'setuptools', - 'WebOb >= 1.7.0rc2', # Response.has_body + 'WebOb >= 1.7.0', # Response.has_body 'zope.interface >= 3.8.0', # has zope.interface.registry 'zope.deprecation >= 3.5.0', # py3 compat - 'venusian >= 1.0a3', # ``ignore`` + 'venusian >= 1.0', # ``ignore`` 'translationstring >= 0.4', # py3 compat 'PasteDeploy >= 1.5.0', # py3 compat 'plaster', @@ -40,7 +40,7 @@ tests_require = [ docs_extras = [ - 'Sphinx >= 1.3.5', + 'Sphinx >= 1.3.5, != 1.7.3', 'docutils', 'repoze.sphinx.autointerface', 'pylons_sphinx_latesturl', @@ -64,7 +64,6 @@ deps = check-manifest [testenv:docs] -skip_install = True basepython = python3.5 whitelist_externals = make commands = @@ -72,7 +71,6 @@ commands = make -C docs doctest html epub BUILDDIR={envdir} "SPHINXOPTS=-W -E" [testenv:pdf] -skip_install = True basepython = python3.5 whitelist_externals = make commands = |
