summaryrefslogtreecommitdiff
path: root/docs/tutorials/wiki2
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-11-09 17:11:16 -0500
committerChris McDonough <chrism@plope.com>2013-11-09 17:11:16 -0500
commit0dcd56c2c30863c6683c0cf442aa73dfdcd11b13 (patch)
tree0f5ad0df850b40990ef8d1bf7764d3422276a147 /docs/tutorials/wiki2
parentc126033112e468cdf858c7c1ad0bb29e7f57f520 (diff)
downloadpyramid-0dcd56c2c30863c6683c0cf442aa73dfdcd11b13.tar.gz
pyramid-0dcd56c2c30863c6683c0cf442aa73dfdcd11b13.tar.bz2
pyramid-0dcd56c2c30863c6683c0cf442aa73dfdcd11b13.zip
undeprecate remember/forget functions and remove remember_userid/forget_userid methods from request
Diffstat (limited to 'docs/tutorials/wiki2')
-rw-r--r--docs/tutorials/wiki2/authorization.rst16
-rw-r--r--docs/tutorials/wiki2/src/authorization/tutorial/views.py22
-rw-r--r--docs/tutorials/wiki2/src/tests/tutorial/views.py23
3 files changed, 38 insertions, 23 deletions
diff --git a/docs/tutorials/wiki2/authorization.rst b/docs/tutorials/wiki2/authorization.rst
index 830cb0277..1e5d0dcbf 100644
--- a/docs/tutorials/wiki2/authorization.rst
+++ b/docs/tutorials/wiki2/authorization.rst
@@ -221,23 +221,23 @@ Add the following import statements to the
head of ``tutorial/tutorial/views.py``:
.. literalinclude:: src/authorization/tutorial/views.py
- :lines: 9-12,19
+ :lines: 9-19
:linenos:
- :emphasize-lines: 3,5
+ :emphasize-lines: 3,6-9,11
:language: python
(Only the highlighted lines need to be added.)
-:func:`~pyramid.view.forbidden_view_config` will be used
+:meth:`~pyramid.view.forbidden_view_config` will be used
to customize the default 403 Forbidden page.
-:meth:`~pyramid.request.Request.remember_userid` and
-:meth:`~pyramid.request.Request.forget_userid` help to create and
+:meth:`~pyramid.security.remember` and
+:meth:`~pyramid.security.forget` help to create and
expire an auth ticket cookie.
Now add the ``login`` and ``logout`` views:
.. literalinclude:: src/authorization/tutorial/views.py
- :lines: 85-115
+ :lines: 91-123
:linenos:
:language: python
@@ -289,7 +289,7 @@ like this:
(Only the highlighted line needs to be added.)
-The :attr:`~pyramid.request.Request.authenticated_userid` property will return
+The :meth:`~pyramid.request.Request.authenticated_userid` property will be
``None`` if the user is not authenticated.
Add a "Logout" link when logged in
@@ -338,7 +338,7 @@ when we're done:
.. literalinclude:: src/authorization/tutorial/views.py
:linenos:
- :emphasize-lines: 11,19,25,31,52,55,67,70,82,85-115
+ :emphasize-lines: 11,14-19,25,31,37,58,61,73,76,88,91-117,119-123
:language: python
(Only the highlighted lines need to be added.)
diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/views.py b/docs/tutorials/wiki2/src/authorization/tutorial/views.py
index 110d738c2..e954d5a31 100644
--- a/docs/tutorials/wiki2/src/authorization/tutorial/views.py
+++ b/docs/tutorials/wiki2/src/authorization/tutorial/views.py
@@ -11,12 +11,18 @@ from pyramid.view import (
forbidden_view_config,
)
+from pyramid.security import (
+ remember,
+ forget,
+ )
+
+from .security import USERS
+
from .models import (
DBSession,
Page,
)
-from .security import USERS
# regular expression used to find WikiWords
wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)")
@@ -78,8 +84,8 @@ def edit_page(request):
pagename=pagename))
return dict(
page=page,
- save_url = request.route_url('edit_page', pagename=pagename),
- logged_in=request.authenticated_userid,
+ save_url=request.route_url('edit_page', pagename=pagename),
+ logged_in=request.authenticated_userid
)
@view_config(route_name='login', renderer='templates/login.pt')
@@ -97,8 +103,9 @@ def login(request):
login = request.params['login']
password = request.params['password']
if USERS.get(login) == password:
- request.remember_userid(login)
- return HTTPFound(location = came_from)
+ headers = remember(request, login)
+ return HTTPFound(location = came_from,
+ headers = headers)
message = 'Failed login'
return dict(
@@ -111,6 +118,7 @@ def login(request):
@view_config(route_name='logout')
def logout(request):
- request.forget_userid()
- return HTTPFound(location = request.route_url('view_wiki'))
+ headers = forget(request)
+ return HTTPFound(location = request.route_url('view_wiki'),
+ headers = headers)
diff --git a/docs/tutorials/wiki2/src/tests/tutorial/views.py b/docs/tutorials/wiki2/src/tests/tutorial/views.py
index 110d738c2..41bea4785 100644
--- a/docs/tutorials/wiki2/src/tests/tutorial/views.py
+++ b/docs/tutorials/wiki2/src/tests/tutorial/views.py
@@ -11,12 +11,18 @@ from pyramid.view import (
forbidden_view_config,
)
+from pyramid.security import (
+ remember,
+ forget,
+ )
+
+from .security import USERS
+
from .models import (
DBSession,
Page,
)
-from .security import USERS
# regular expression used to find WikiWords
wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)")
@@ -78,8 +84,8 @@ def edit_page(request):
pagename=pagename))
return dict(
page=page,
- save_url = request.route_url('edit_page', pagename=pagename),
- logged_in=request.authenticated_userid,
+ save_url=request.route_url('edit_page', pagename=pagename),
+ logged_in=request.authenticated_userid
)
@view_config(route_name='login', renderer='templates/login.pt')
@@ -97,8 +103,9 @@ def login(request):
login = request.params['login']
password = request.params['password']
if USERS.get(login) == password:
- request.remember_userid(login)
- return HTTPFound(location = came_from)
+ headers = remember(request, login)
+ return HTTPFound(location = came_from,
+ headers = headers)
message = 'Failed login'
return dict(
@@ -111,6 +118,6 @@ def login(request):
@view_config(route_name='logout')
def logout(request):
- request.forget_userid()
- return HTTPFound(location = request.route_url('view_wiki'))
-
+ headers = forget(request)
+ return HTTPFound(location = request.route_url('view_wiki'),
+ headers = headers)