Skip to content

Instantly share code, notes, and snippets.

@Tukki
Last active August 29, 2015 14:01
Show Gist options
  • Save Tukki/18836ecae196006ae886 to your computer and use it in GitHub Desktop.
Save Tukki/18836ecae196006ae886 to your computer and use it in GitHub Desktop.
voluptuous demo
def validate_iid(iid):
    pass


def get_action_id(action_name):
    pass


def form_error_to_json(view_func):
    pass


ActionSchema = Schema({
    'iid': validate_iid,
    'action': get_action_id,
    },
    request=True)


@form_error_to_json
def api(request):
    params = ActionSchema({
        'iid': reqeust.GET.get('iid'),
        'action': request.POST.get('action'),
        })

    iid = params['iid']
    action = params['action']

    # palapala
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment