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

« back to all changes in this revision

Viewing changes to ivle/webapp/filesystem/serve/__init__.py

  • Committer: David Coles
  • Date: 2010-07-28 10:45:53 UTC
  • mfrom: (1829 trunk)
  • mto: This revision was merged to the branch mainline in revision 1830.
  • Revision ID: coles.david@gmail.com-20100728104553-5z3nxt0l6kyfqfh5
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
import os
28
28
 
29
 
import cjson
 
29
try:
 
30
    import json
 
31
except ImportError:
 
32
    import simplejson as json
30
33
 
31
34
from ivle import (studpath, interpret)
32
35
from ivle.database import User
112
115
        assert not err
113
116
 
114
117
        # Remove the JSON from the front of the response, and decode it.
115
 
        json = out.split('\n', 1)[0]
116
 
        out = out[len(json) + 1:]
117
 
        response = cjson.decode(json)
 
118
        j = out.split('\n', 1)[0]
 
119
        out = out[len(j) + 1:]
 
120
        response = json.loads(j)
118
121
 
119
122
        if 'error' in response:
120
123
            if response['error'] == 'not-found':
135
138
            req.headers_out["Content-Disposition"] = (
136
139
                         "attachment; filename=%s" %
137
140
                             response['name'].encode('utf-8'))
138
 
        req.content_type = response['type']
 
141
        req.content_type = response['type'].encode('utf-8')
139
142
        req.content_length = response.get('size')
140
143
        req.write(out)
141
144