Merge remote-tracking branch 'upstream/master'
| | |
| | | invoked from ``request.invoke_exception_view``. |
| | | See https://github.com/Pylons/pyramid/pull/3060 |
| | | |
| | | - Fix a bug in which ``pyramid.security.ALL_PERMISSIONS`` failed to return |
| | | a valid iterator in its ``__iter__`` implementation. |
| | | See https://github.com/Pylons/pyramid/pull/3074 |
| | | |
| | | 1.9a2 (2017-05-09) |
| | | ================== |
| | | |
| | |
| | | - Jeremy(Ching-Rui) Chen, 2017/04/19 |
| | | |
| | | - Fang-Pen Lin, 2017/05/22 |
| | | |
| | | - Volker Diels-Grabsch, 2017/06/09 |
| | |
| | | ``$VENV/bin/pip`` clearly specifies that ``pip`` is run from within the |
| | | virtual environment and not at the system level. |
| | | |
| | | ``activate`` drops turds into the user's shell environment, leaving them |
| | | vulnerable to executing commands in the wrong context. ``deactivate`` might |
| | | not correctly restore previous shell environment variables. |
| | | ``activate`` makes changes to the user's shell environment which can often be convenient. However, in the context of long-form documentation, environment configuration can easily be forgotten. By keeping each snippet explicit we can reduce copy / paste errors by users in which commands are executed against the wrong Python environment. Also, ``deactivate`` might not correctly restore previous shell environment variables. Avoiding ``activate`` keeps the environment more reproducible. |
| | | |
| | | Although using ``source bin/activate``, then ``pip``, requires fewer key |
| | | strokes to issue commands once invoked, there are other things to consider. |
| | |
| | | |
| | | """ |
| | | settings = config.get_settings() |
| | | |
| | | settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' |
| | | # use pyramid_tm to hook the transaction lifecycle to the request |
| | | config.include('pyramid_tm') |
| | | |
| | |
| | | .. literalinclude:: src/models/tutorial/models/__init__.py |
| | | :linenos: |
| | | :language: py |
| | | :emphasize-lines: 8,9 |
| | | :emphasize-lines: 10,11 |
| | | |
| | | Here we align our imports with the names of the models, ``Page`` and ``User``. |
| | | |
| | |
| | | |
| | | """ |
| | | settings = config.get_settings() |
| | | settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' |
| | | |
| | | # use pyramid_tm to hook the transaction lifecycle to the request |
| | | config.include('pyramid_tm') |
| | |
| | | |
| | | """ |
| | | settings = config.get_settings() |
| | | settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' |
| | | |
| | | # use pyramid_tm to hook the transaction lifecycle to the request |
| | | config.include('pyramid_tm') |
| | |
| | | |
| | | """ |
| | | settings = config.get_settings() |
| | | settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' |
| | | |
| | | # use pyramid_tm to hook the transaction lifecycle to the request |
| | | config.include('pyramid_tm') |
| | |
| | | |
| | | """ |
| | | settings = config.get_settings() |
| | | settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' |
| | | |
| | | # use pyramid_tm to hook the transaction lifecycle to the request |
| | | config.include('pyramid_tm') |
| | |
| | | """ This function returns a Pyramid WSGI application. |
| | | """ |
| | | config = Configurator(settings=settings) |
| | | settings = config.get_settings() |
| | | settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' |
| | | config.include('pyramid_jinja2') |
| | | config.include('.models') |
| | | config.include('.routes') |
| | |
| | | |
| | | """ |
| | | settings = config.get_settings() |
| | | settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' |
| | | |
| | | # use pyramid_tm to hook the transaction lifecycle to the request |
| | | config.include('pyramid_tm') |
| | |
| | | |
| | | """ |
| | | settings = config.get_settings() |
| | | settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' |
| | | |
| | | # use pyramid_tm to hook the transaction lifecycle to the request |
| | | config.include('pyramid_tm') |
| | |
| | | |
| | | """ |
| | | settings = config.get_settings() |
| | | settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' |
| | | |
| | | # use pyramid_tm to hook the transaction lifecycle to the request |
| | | config.include('pyramid_tm') |
| | |
| | | from pyramid.view import forbidden_view_config |
| | | |
| | | @forbidden_view_config() |
| | | def basic_challenge(request): |
| | | response = HTTPUnauthorized() |
| | | response.headers.update(forget(request)) |
| | | return response |
| | | def forbidden_view(request): |
| | | if request.authenticated_userid is None: |
| | | response = HTTPUnauthorized() |
| | | response.headers.update(forget(request)) |
| | | return response |
| | | return HTTPForbidden() |
| | | """ |
| | | def __init__(self, check, realm='Realm', debug=False): |
| | | self.check = check |
| | |
| | | |
| | | """ |
| | | settings = config.get_settings() |
| | | settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' |
| | | |
| | | # use pyramid_tm to hook the transaction lifecycle to the request |
| | | config.include('pyramid_tm') |
| | |
| | | """ This function returns a Pyramid WSGI application. |
| | | """ |
| | | config = Configurator(root_factory=root_factory, settings=settings) |
| | | settings = config.get_settings() |
| | | settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' |
| | | config.include('pyramid_chameleon') |
| | | config.add_static_view('static', 'static', cache_max_age=3600) |
| | | config.scan() |
| | |
| | | |
| | | class AllPermissionsList(object): |
| | | """ Stand in 'permission list' to represent all permissions """ |
| | | |
| | | def __iter__(self): |
| | | return () |
| | | return iter(()) |
| | | |
| | | def __contains__(self, other): |
| | | return True |
| | | |
| | | def __eq__(self, other): |
| | | return isinstance(other, self.__class__) |
| | | |
| | |
| | | def _makeOne(self): |
| | | return self._getTargetClass()() |
| | | |
| | | def test_it(self): |
| | | def test_equality_w_self(self): |
| | | thing = self._makeOne() |
| | | self.assertTrue(thing.__eq__(thing)) |
| | | self.assertEqual(thing.__iter__(), ()) |
| | | |
| | | def test_equality_w_other_instances_of_class(self): |
| | | thing = self._makeOne() |
| | | other = self._makeOne() |
| | | self.assertTrue(thing.__eq__(other)) |
| | | |
| | | def test_equality_miss(self): |
| | | thing = self._makeOne() |
| | | other = object() |
| | | self.assertFalse(thing.__eq__(other)) |
| | | |
| | | def test_contains_w_string(self): |
| | | thing = self._makeOne() |
| | | self.assertTrue('anything' in thing) |
| | | |
| | | def test_contains_w_object(self): |
| | | thing = self._makeOne() |
| | | self.assertTrue(object() in thing) |
| | | |
| | | def test_iterable(self): |
| | | thing = self._makeOne() |
| | | self.assertEqual(list(thing), []) |
| | | |
| | | def test_singleton(self): |
| | | from pyramid.security import ALL_PERMISSIONS |
| | | self.assertEqual(ALL_PERMISSIONS.__class__, self._getTargetClass()) |
| | |
| | | response. Otherwise the previous values for ``request.exception`` and |
| | | ``request.exc_info`` will be restored. |
| | | |
| | | .. versionadded:: 1.7 |
| | | |
| | | .. versionchanged:: 1.9 |
| | | The ``request.exception`` and ``request.exc_info`` properties will |
| | | reflect the exception used to render the response where previously |