Beispiel #1
0
  def _authorizationCallback(self, result, app, request, repository):
    assert isinstance(result, bool) or isinstance(result, dict)
    assert isinstance(app, Factory)
    assert IRequest.providedBy(request)

    """Callback for the dereferred returned by the authorization subsystem."""

    if result:
      if not isinstance(result, dict):
        result = {}

      request.finish(repository, result)
    else:
      app.getErrorHandler().handle(UnauthorizedRepositoryException(request.getProtocol()))
Beispiel #2
0
  def handle(self, app, request):
    assert isinstance(app, Factory)
    assert IRequest.providedBy(request)

    repository = app.getRepositoryRouter().route(app, request.getRepositoryPath())

    if repository is not None:
      # authorizeRepository can return a deferred that returns a value or just return a value
      # many authorization requests go to another subsystem first

      d = maybeDeferred(app.getAuth().authorizeRepository, request.getSession(), repository, request.getType())
      d.addCallback(self._authorizationCallback, app, request, repository)
      d.addErrback(authorization.authorizationErrorHandler, app, request.getProtocol())
    else:
      app.getErrorHandler().handle(UnexistingRepositoryException(request.getProtocol()))