collective.checkpermission
==========================

Sometimes you may want to protect a browser view method against a particular permission.
Using the provided check_permission decorator you will be able to protect those methods without 
having to modify your methods code.

The decorator uses internally a multiadapter, you will be able to have different settings for context
and type of view.

    >>> from Products.Five.browser import BrowserView
    >>> from collective.checkpermission.check import check_permission
    >>> class ExampleView(BrowserView):
    ...
    ...     def __call__(self):
    ...         return 'OK'
    ...     
    ...     @check_permission('Modify portal content')
    ...     def protected_method(self):
    ...         return 'PROTECTED'
    >>> example_view = ExampleView(self.folder, self.folder.REQUEST)
    >>> example_view()
    'OK'
    >>> example_view.protected_method()
    'PROTECTED'

Here I am not logged-in. 

    >>> self.logout()


    >>> example_view = ExampleView(self.folder, self.folder.REQUEST)
    >>> example_view()
    'OK'

    >>> from AccessControl import Unauthorized
    >>> not self.assertRaises(Unauthorized, example_view.protected_method)
    True



