Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(32)  |  Call(22)  |  Derive(0)  |  Import(10)

src/m/a/max-3.6/max/rest/conversations.py   max(Download)
from pymongo import ASCENDING
 
from max.exceptions import ValidationError, Unauthorized, Forbidden, ObjectNotFound
from max.MADMax import MADMaxDB, MADMaxCollection
from max.models import Message, Conversation, Activity
    cid = request.matchdict['id']
    if cid not in [ctxt.get("id", '') for ctxt in request.actor.talkingIn]:
        raise Unauthorized('User {} is not allowed to view this conversation'.format(request.actor.username))
 
    mmdb = MADMaxDB(context.db)
 
    if cid not in [ctxt.get("id", '') for ctxt in request.actor.talkingIn]:
        raise Unauthorized('User {} is not allowed to view this conversation'.format(request.actor.username))
 
    # In two people conversations, force displayName to the displayName of
 
    if not auth_user_is_conversation_owner:
        raise Unauthorized('Only the owner modify conversation properties')
 
    properties = conversation.getMutablePropertiesFromRequest(request)
                conversation._owner != request.creator:
 
            raise Unauthorized('User {0} cannot subscribe himself to to this context'.format(actor['username']))
 
        actor.addSubscription(conversation)

src/m/a/max-3.6/max/decorators.py   max(Download)
# -*- coding: utf-8 -*-
from max.exceptions import MissingField, ObjectNotSupported, ObjectNotFound, DuplicatedItemError, UnknownUserError, Unauthorized, InvalidSearchParams, InvalidPermission, ValidationError, Forbidden
from max.exceptions import JSONHTTPUnauthorized, JSONHTTPBadRequest, JSONHTTPNotFound, JSONHTTPForbidden, JSONHTTPInternalServerError
from bson.errors import InvalidId
from max.MADMax import MADMaxDB
            if force_own:
                if username != oauth_username:
                    raise Unauthorized("You don't have permission to access %s resources" % (username))
 
            def getActor(request):

src/m/a/max-3.6/max/rest/admin/contexts.py   max(Download)
from max.models import Context
from max.rest.utils import searchParams, extractPostData
from max.exceptions import InvalidPermission, Unauthorized, ObjectNotFound, ValidationError
from max.rest.ResourceHandlers import JSONResourceEntity, JSONResourceRoot
 
 
    if not subscription:
        raise Unauthorized("You can't set permissions on a context where the user is not subscribed")
 
    #If we reach here, we are subscribed to a context and ready to set the permission
 
    if not subscription:
        raise Unauthorized("You can't set permissions on a context where the user is not subscribed")
 
    #If we reach here, we are subscribed to a context and ready to reset the permissions
 
    if not subscription:
        raise Unauthorized("You can't remove permissions on a context where you are not subscribed")
 
    #If we reach here, we are subscribed to a context and ready to remove the permission

src/m/a/max-3.6/max/rest/activities.py   max(Download)
from max.decorators import MaxResponse, requirePersonActor
from max.oauth2 import oauth2
from max.exceptions import ObjectNotFound, Unauthorized, Forbidden
 
from max.rest.ResourceHandlers import JSONResourceRoot, JSONResourceEntity
        found_activity.delete()
    else:
        raise Unauthorized("You're not the owner of this activity, so you can't delete it")
 
    return HTTPNoContent()

src/m/a/max-3.6/max/rest/subscriptions.py   max(Download)
from max import DEFAULT_CONTEXT_PERMISSIONS
from max.oauth2 import oauth2
from max.exceptions import Unauthorized, ObjectNotFound
from max.decorators import MaxResponse, requirePersonActor
from max.MADMax import MADMaxCollection
        scontext = contexts[newactivity['object'].getHash()]
        if scontext.permissions.get('subscribe', DEFAULT_CONTEXT_PERMISSIONS['subscribe']) == 'restricted':
            raise Unauthorized('User {0} cannot subscribe himself to to this context'.format(actor['username']))
        actor.addSubscription(scontext)
 
 
    if 'unsubscribe' not in subscription.get('permissions', []):
        raise Unauthorized('User {0} cannot unsubscribe himself from this context'.format(actor.username))
 
    found_context = mmdb.contexts.getItemsByhash(chash)

src/m/a/max-3.6/max/rest/comments.py   max(Download)
from max.rest.ResourceHandlers import JSONResourceRoot, JSONResourceEntity
from max.decorators import MaxResponse, requirePersonActor
from max.exceptions import ObjectNotFound, Unauthorized
from max.models import Activity
from max.oauth2 import oauth2
        found_activity.delete_comment(commentid)
    else:
        raise Unauthorized("You're not allowed to delete this comment")
 
    return HTTPNoContent()

src/m/a/max-3.6/max/oauth2.py   max(Download)
from max.exceptions import Unauthorized
from max.resources import getMAXSettings
from max.resources import Root
 
from pyramid.settings import asbool
                # This is for mental sanity in case we miss the body part when writing tests
                if 'X-Oauth-Username' in request.params.keys():
                    raise Unauthorized("Authorization found in url params, not in request. Check your tests, you may be passing the authentication headers as the request body...")
 
                raise Unauthorized('No auth headers found.')
 
            if scope not in allowed_scopes:
                raise Unauthorized('The specified scope is not allowed for this resource.')
                return view_function(*args, **kw)
            else:
                raise Unauthorized('Invalid token.')
 
        new_function.__doc__ = view_function.__doc__

src/m/a/max-3.6/max/rest/utils.py   max(Download)
from datetime import datetime
from rfc3339 import rfc3339
from max.exceptions import InvalidSearchParams, Unauthorized
from pyramid.threadlocal import get_current_registry
from pyramid.settings import asbool
            subscription = subscriptions.get(context.getIdentifier(), None)
            if subscription is None:
                raise Unauthorized("You are not subscribed to this context : %s" % context.getIdentifier())
 
        # If user is trying to post on a subscribed context/s
        # Check that has write permission in all the contexts
 
        allowed_to_write = hasPermission(subscription, 'write')
        if not allowed_to_write:
            raise Unauthorized("You are not allowed to post to this context : %s" % context.getIdentifier())
        containments = [usc.startswith(url) for usc in subscribed_contexts_urls]
        if True not in containments:
            raise Unauthorized("You are not subscribed to this context: %s" % url)
 
    #If we reached here, we have permission to read on all contexts

src/m/a/max-3.6/max/rest/contexts.py   max(Download)
from max import LAST_AUTHORS_LIMIT, AUTHORS_SEARCH_MAX_QUERIES_LIMIT
from max.MADMax import MADMaxDB
from max.exceptions import Unauthorized, ObjectNotFound
from max.oauth2 import oauth2
from max.decorators import MaxResponse, requirePersonActor
    is_subscribed = chash in [subscription['hash'] for subscription in actor.subscribedTo]
    if not is_subscribed:
        raise Unauthorized("You're not allowed to access this context")
 
    query = {}

src/m/a/max-3.6/max/rest/people.py   max(Download)
from pyramid.response import Response
 
from max.exceptions import Unauthorized
from max.exceptions import ValidationError
from max.exceptions import ObjectNotFound