Example #1
0
def parse_my_projects_arg():
    """Parse my-projects request argument and save result to g.my_projects"""
    try:
        g.my_projects = boolean_from_string(request.args['my-projects'])
        g.unused_args.discard('my-projects')
    except KeyError:
        g.my_projects = not g.is_admin
    except ValueError:
        raise exc.InvalidArgumentValue('my-projects', 'boolean',
                                       request.args.get('my-projects'))
    if not g.my_projects and not g.is_admin:
        raise exc.InvalidArgumentValue('my-projects', 'boolean', False,
                               'Only administrators are allowed '
                               'to set my-projects to false')
Example #2
0
 def from_argument(self, value):
     return boolean_from_string(value, self._illegal_argument)