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

« back to all changes in this revision

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

This commit changes the tutorial service, which now almost exclusively
uses the database to store its data.

Whilst the modifications to tutorial are not yet complete, this commit
should stabilise the database model.

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 == 'True' or value == 'true' or value == True:
 
65
            return True
 
66
        elif value == 'False' or value == 'False' or value == 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']