Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Pylons/pyramid
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdonc committed Sep 2, 2015
2 parents 94853b4 + f17b973 commit b9b68fe
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 41 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ Bug Fixes
default to an iterable instead of ``None``. It may be checked for a length
of 0. This was the behavior in 1.5.

- ``pyramid.httpexceptions.HTTPException`` now defaults to
``520 Unknown Error`` instead of ``None None`` to conform with changes in
WebOb 1.5.
See https://github.com/Pylons/pyramid/pull/1865

Deprecations
------------

Expand Down
41 changes: 14 additions & 27 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,24 @@ def nothing(*arg):

# Looks for objects in external projects
intersphinx_mapping = {
'tutorials': ('http://docs.pylonsproject.org/projects/pyramid-tutorials/en/latest/', None),
'colander': ( 'http://docs.pylonsproject.org/projects/colander/en/latest', None),
'cookbook': ('http://docs.pylonsproject.org/projects/pyramid-cookbook/en/latest/', None),
'deform': ('http://docs.pylonsproject.org/projects/deform/en/latest', None),
'jinja2': ('http://docs.pylonsproject.org/projects/pyramid-jinja2/en/latest/', None),
'tm': (
'http://docs.pylonsproject.org/projects/pyramid_tm/en/latest/',
None,
),
'zcomponent': ('http://docs.zope.org/zope.component', None),
'webtest': ('http://webtest.pythonpaste.org/en/latest', None),
'webob': ('http://docs.webob.org/en/latest', None),
'colander': (
'http://docs.pylonsproject.org/projects/colander/en/latest',
None),
'deform': (
'http://docs.pylonsproject.org/projects/deform/en/latest',
None),
'sqla': ('http://docs.sqlalchemy.org/en/latest', None),
'who': ('http://repozewho.readthedocs.org/en/latest', None),
'pylonswebframework': ('http://docs.pylonsproject.org/projects/pylons-webframework/en/latest/', None),
'python': ('http://docs.python.org', None),
'python3': ('http://docs.python.org/3', None),
'tstring':
('http://docs.pylonsproject.org/projects/translationstring/en/latest',
None),
'venusian':
('http://docs.pylonsproject.org/projects/venusian/en/latest', None),
'toolbar':
('http://docs.pylonsproject.org/projects/pyramid-debugtoolbar/en/latest',
None),
'zcml':
('http://docs.pylonsproject.org/projects/pyramid-zcml/en/latest',
None),
'sqla': ('http://docs.sqlalchemy.org/en/latest', None),
'tm': ('http://docs.pylonsproject.org/projects/pyramid_tm/en/latest/', None),
'toolbar': ('http://docs.pylonsproject.org/projects/pyramid-debugtoolbar/en/latest', None),
'tstring': ('http://docs.pylonsproject.org/projects/translationstring/en/latest', None),
'tutorials': ('http://docs.pylonsproject.org/projects/pyramid-tutorials/en/latest/', None),
'venusian': ('http://docs.pylonsproject.org/projects/venusian/en/latest', None),
'webob': ('http://docs.webob.org/en/latest', None),
'webtest': ('http://webtest.pythonpaste.org/en/latest', None),
'who': ('http://repozewho.readthedocs.org/en/latest', None),
'zcml': ('http://docs.pylonsproject.org/projects/pyramid-zcml/en/latest', None),
'zcomponent': ('http://docs.zope.org/zope.component', None),
}


Expand Down
7 changes: 3 additions & 4 deletions docs/narr/i18n.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,9 @@ by creating various kinds of gettext files.
The steps a developer must take to work with :term:`gettext`
:term:`message catalog` files within a :app:`Pyramid`
application are very similar to the steps a :term:`Pylons`
developer must take to do the same. See the `Pylons
internationalization documentation
<http://wiki.pylonshq.com/display/pylonsdocs/Internationalization+and+Localization>`_
for more information.
developer must take to do the same. See the :ref:`Pylons
Internationalization and Localization documentation
<pylonswebframework:i18n>` for more information.

GNU gettext uses three types of files in the translation framework,
``.pot`` files, ``.po`` files and ``.mo`` files.
Expand Down
5 changes: 5 additions & 0 deletions docs/narr/scaffolding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ As you create files and directories within the template directory, note that:
have that string replaced with the value of the ``var`` variable provided
to the scaffold.

- Files that start with a dot (e.g., ``.env``) are ignored and will not be
copied over to the destination directory. If you want to include a file with
a leading dot then you must replace the dot with ``+dot+`` (e.g.,
``+dot+env``).

Otherwise, files and directories which live in the template directory will be
copied directly without modification to the ``pcreate`` output location.

Expand Down
3 changes: 0 additions & 3 deletions docs/quick_tutorial/authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ Extra Credit

#. Can I use a database behind my ``groupfinder`` to look up principals?

#. Do I have to put a ``renderer`` in my ``@forbidden_view_config``
decorator?

#. Once I am logged in, does any user-centric information get jammed
onto each request? Use ``import pdb; pdb.set_trace()`` to answer
this.
Expand Down
3 changes: 3 additions & 0 deletions docs/quick_tutorial/authorization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ by decorating the view with ``@forbidden_view_config``.
Extra Credit
============

#. Do I have to put a ``renderer`` in my ``@forbidden_view_config``
decorator?

#. Perhaps you would like the experience of not having enough permissions
(forbidden) to be richer. How could you change this?

Expand Down
11 changes: 9 additions & 2 deletions pyramid/httpexceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ class HTTPException(Response, Exception):
# title = 'OK'
# explanation = 'why this happens'
# body_template_obj = Template('response template')
#
# This class itself uses the error code "520" with the error message/title
# of "Unknown Error". This is not an RFC standard, however it is
# implemented in practice. Sub-classes should be overriding the default
# values and 520 should not be seen in the wild from Pyramid applications.
# Due to changes in WebOb, a code of "None" is not valid, and WebOb due to
# more strict error checking rejects it now.

# differences from webob.exc.WSGIHTTPException:
#
Expand All @@ -178,8 +185,8 @@ class HTTPException(Response, Exception):
#
# - documentation improvements (Pyramid-specific docstrings where necessary)
#
code = None
title = None
code = 520
title = 'Unknown Error'
explanation = ''
body_template_obj = Template('''\
${explanation}${br}${br}
Expand Down
4 changes: 2 additions & 2 deletions pyramid/tests/test_httpexceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_ctor_calls_Exception_ctor(self):

def test_ctor_calls_Response_ctor(self):
exc = self._makeOne('message')
self.assertEqual(exc.status, 'None None')
self.assertEqual(exc.status, '520 Unknown Error')

def test_ctor_extends_headers(self):
exc = self._makeOne(headers=[('X-Foo', 'foo')])
Expand Down Expand Up @@ -329,7 +329,7 @@ def test_it_call_with_default_body_tmpl(self):
start_response = DummyStartResponse()
app_iter = exc(environ, start_response)
self.assertEqual(app_iter[0],
(b'None None\n\nThe resource has been moved to foo; '
(b'520 Unknown Error\n\nThe resource has been moved to foo; '
b'you should be redirected automatically.\n\n'))

class TestHTTPForbidden(unittest.TestCase):
Expand Down
13 changes: 10 additions & 3 deletions pyramid/tests/test_session.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import base64
import json
import unittest
from pyramid import testing
Expand Down Expand Up @@ -277,7 +278,7 @@ def _makeOne(self, request, **kw):
return BaseCookieSessionFactory(serializer, **kw)(request)

def _serialize(self, value):
return json.dumps(value)
return base64.b64encode(json.dumps(value).encode('utf-8'))

def test_reissue_not_triggered(self):
import time
Expand Down Expand Up @@ -650,10 +651,16 @@ def test_failure_no_raises(self):

class DummySerializer(object):
def dumps(self, value):
return json.dumps(value).encode('utf-8')
return base64.b64encode(json.dumps(value).encode('utf-8'))

def loads(self, value):
return json.loads(value.decode('utf-8'))
try:
return json.loads(base64.b64decode(value).decode('utf-8'))

# base64.b64decode raises a TypeError on py2 instead of a ValueError
# and a ValueError is required for the session to handle it properly
except TypeError:
raise ValueError

class DummySessionFactory(dict):
_dirty = False
Expand Down

0 comments on commit b9b68fe

Please sign in to comment.