Пример #1
0
def explode_no_auth(real_user, user, type=None, **kw):
    """
    An action to test the error handling of the stack. The tests use this.
    """
    if type == 'app':
        raise AppException('This is an app exception!',
                           code=INVALID,
                           field='type')
    elif type == 'client':
        raise ClientException('Oh Noes, ClientException!',
                              code=INVALID,
                              field='type')
    elif type == 'client404':
        raise ClientException('Oh Noes, ClientException NOT FOUND!',
                              code=NOT_FOUND,
                              field='type')
    elif type == 'client403':
        raise ClientException('Oh Noes, ClientException FORBIDDEN!',
                              code=FORBIDDEN,
                              field='type')
    elif type == 'explosion':
        1 / 0
    elif type == 'http':
        abort(404, 'This thing was not found!')
    elif type == 'validation':

        class Rawr(formencode.Schema):
            meow = fv.Number()

        scrubbed = validate(Rawr, meow='zzzz')

    return kw
Пример #2
0
def get(u=None, username=None):
    if not u and not username:
        abort(403)
    elif u: return u
    
    u = Session.query(users.User).filter_by(username=username).first()
    if not u:
        abort(403)
    
    return u
Пример #3
0
def get_structure(real_user, user, organization=None):
    """
    get the org and all projects. Serializer does most the work.
    """
    if not organization:
        abort(404)
    
    projects = organization.get_projects(user)
    
    return (organization, projects)
Пример #4
0
def get_structure(real_user, user, organization=None):
    """
    get the org and all projects. Serializer does most the work.
    """
    if not organization:
        abort(404)

    projects = organization.get_projects(user)

    return (organization, projects)
Пример #5
0
def get(u=None, username=None):
    if not u and not username:
        abort(403)
    elif u:
        return u

    u = Session.query(users.User).filter_by(username=username).first()
    if not u:
        abort(403)

    return u
Пример #6
0
def get(real_user, user, organization, project=None):
    if not user and not project:
        abort(403)
    
    if project:
        q = Session.query(projects.Project).filter_by(organization=organization)
        p = q.filter(sa.or_(projects.Project.eid==project, projects.Project.slug==project)).first()
        CanReadProject().check(real_user, user, project=p)
        return p
    
    #this will do the check to make sure to return only projects the user can see
    return organization.get_projects(user)
Пример #7
0
def explode_no_auth(real_user, user, type=None, **kw):
    """
    An action to test the error handling of the stack. The tests use this.
    """
    if type == 'app':
        raise AppException('This is an app exception!', code=INVALID, field='type')
    elif type == 'client':
        raise ClientException('Oh Noes, ClientException!', code=INVALID, field='type')
    elif type == 'client404':
        raise ClientException('Oh Noes, ClientException NOT FOUND!', code=NOT_FOUND, field='type')
    elif type == 'client403':
        raise ClientException('Oh Noes, ClientException FORBIDDEN!', code=FORBIDDEN, field='type')
    elif type == 'explosion':
        1/0
    elif type == 'http':
        abort(404, 'This thing was not found!')
    elif type == 'validation':
        class Rawr(formencode.Schema):
            meow = fv.Number()
        scrubbed = validate(Rawr, meow='zzzz')
    
    return kw