'Override the :app:`Pyramid` :term:`authorization policy` in the
current configuration.  The ``policy`` argument must be an instance
of an authorization policy or a :term:`dotted Python name` that points
at an instance of an authorization policy.
.. note::
Using the ``authorization_policy`` argument to the
:class:`pyramid.config.Configurator` constructor can be used to
achieve the same purpose.'

@action_method
def set_authorization_policy(self, policy):

    def register():
        self._set_authorization_policy(policy)
    def ensure():
        if self.autocommit:
            return
        if (self.registry.queryUtility(IAuthenticationPolicy) is None):
            raise ConfigurationError('Cannot    configure    an    authorization    policy    without    also    configuring    an    authentication    policy    (use    the    set_authorization_policy    method)')
    intr = self.introspectable('authorization    policy', None, self.object_description(policy), 'authorization    policy')
    intr['policy'] = policy
    self.action(IAuthorizationPolicy, register, order=PHASE1_CONFIG, introspectables=(intr,))
    self.action(None, ensure)
