~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/base/rest.py

  • Committer: William Grant
  • Date: 2009-02-25 23:04:11 UTC
  • Revision ID: grantw@unimelb.edu.au-20090225230411-lbdyl32ir0m3d59b
Make all of the services executable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
# Author: Matt Giuca, Will Grant
19
19
 
20
20
import cgi
 
21
import urlparse
21
22
import inspect
22
23
 
23
24
import cjson
58
59
 
59
60
        if op._rest_api_permission not in self.get_permissions(req.user):
60
61
            raise Unauthorized()
 
62
    
 
63
    def convert_bool(self, value):
 
64
        if value in ('True', 'true', True):
 
65
            return True
 
66
        elif value in ('False', 'false', False):
 
67
            return False
 
68
        else:
 
69
            raise BadRequest()
61
70
 
62
71
    def render(self, req):
63
72
        if req.method not in self._allowed_methods:
87
96
        # POST implies named operation.
88
97
        elif req.method == 'POST':
89
98
            # TODO: Check Content-Type and implement multipart/form-data.
90
 
            opargs = dict(cgi.parse_qsl(req.read()))
 
99
            data = req.read()
 
100
            opargs = dict(cgi.parse_qsl(data, keep_blank_values=1))
91
101
            try:
92
102
                opname = opargs['ivle.op']
93
103
                del opargs['ivle.op']