Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add repoze.workflow.has_permission #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
repoze.workflow Changelog
=========================

1.0b2 (unreleased)
------------------

Features
~~~~~~~~

- Add ``repoze.workflow.has_permission`` since as of Pyramid 1.5 the
"pyramid.security.has_permission" API is now deprecated and it will
be removed in Pyramid 1.8

Housekeeping
~~~~~~~~~~~~

- Update permission checker example in ``docs/configuration.rst``

- Add mock library to test requirements

1.0b1 (2014-12-11)
------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ workflow.
state_attr="state"
initial_state="private"
content_types=".dummy.IContent"
permission_checker="repoze.bfg.security.has_permission"
permission_checker="repoze.workflow.has_permission"
>

<state name="private"
Expand Down
1 change: 1 addition & 0 deletions repoze/workflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from repoze.workflow.security import has_permission # API
from repoze.workflow.workflow import Workflow # API
from repoze.workflow.workflow import WorkflowError #API
from repoze.workflow.workflow import get_workflow #API
Expand Down
5 changes: 5 additions & 0 deletions repoze/workflow/security.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def has_permission(permission, context, request):
""" Default permission checker """
return request.has_permission(
permission,
context=context)
20 changes: 20 additions & 0 deletions repoze/workflow/tests/test_security.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import unittest


class HasPermissionTests(unittest.TestCase):

def _get_has_permission(self):
from repoze.workflow import has_permission
return has_permission

def test_has_permission(self):
import mock
has_permission = self._get_has_permission()
permission = 'edit'
context = object()
request = mock.MagicMock()
has_permission(permission, context, request)
self.assertEqual(
request.has_permission.assert_called_once_with(
permission, context=context),
None)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def _read_file(name):

tests_require = [
'zope.testing',
'mock',
]

testing_extras = tests_require + ['nose', 'coverage']
Expand Down