HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/bouncer/__pycache__/__init__.cpython-310.pyc
o

N�>S�	�@s`dZdZddlmZmZddlmZdd�Zdd�Zd	d
�Z	da
dd
�Zdd�ZdZ
dd�ZdS)z�
    bouncer
    -------

    Simple Declarative Authentication DSL inspired by Ryan Bates excellent cancan library

    :copyright:  (c) 2014 by Jonathan Tushman.
    :license:    MIT, see LICENSE for more details.
�jtushman�)�Rule�Ability)�AccessDeniedcC�t|t��}|�||�S)aMChecks if a given user has the ability to perform the action on a subject

    :param user: A user object
    :param action: an action string, typically 'read', 'edit', 'manage'.  Use bouncer.constants for readability
    :param subject: the resource in question.  Either a Class or an instance of a class.  Pass the class if you
                    want to know if the user has general access to perform the action on that type of object.  Or
                    pass a specific object, if you want to know if the user has the ability to that specific instance

    :returns: Boolean
    �r�get_authorization_method�can��user�action�subject�ability�r�I/home/arjun/projects/env/lib/python3.10/site-packages/bouncer/__init__.pyr	sr	cCr)zinverse of ``can``)rr�cannotr
rrrrsrcCs"t|t��}|�||�rt��dS)zS Similar to ``can`` but will raise a AccessDenied Exception if does not have accessN)rrrrr
rrr�ensure%s�rNcCs|a|S)zWThe method that will be injected into the authorization target to perform authorization��_authorization_method)�original_methodrrr�authorization_method-srcCstS�Nrrrrrr4srcs0dd���fdd�}t|d��t|d|�|S)z� Add bouncer goodness to the model.  This is a class decorator, when added to your User model if will add
        ``can`` and ``cannot`` methods to the class
    :param original_class:  the User class to be decorated
    cSrrr)�selfrr
rrrrr	@sz!authorization_target.<locals>.cancs�|||�Srr)rrr
�r	rrrDsz$authorization_target.<locals>.cannotr	r)�setattr)�original_classrrrr�authorization_target:s
r)�__doc__�
__author__�bouncer.modelsrr�bouncer.exceptionsrr	rrrrr�_authorization_targetrrrrr�<module>s