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

« back to all changes in this revision

Viewing changes to services/serveservice

  • Committer: William Grant
  • Date: 2010-02-11 11:33:33 UTC
  • Revision ID: grantw@unimelb.edu.au-20100211113333-0j040ct188bfpjl5
Add subject creation/editing UI. Not linked just yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
from ivle import zip as zipmod
31
31
import ivle.conf.app.server
 
32
import ivle.mimetypes
32
33
 
33
34
def determine_file_type(filename):
34
35
    filetype = mimetypes.guess_type(filename)[0]
35
36
    if filetype is None:
36
 
         filetype = ivle.conf.mimetypes.default_mimetype
 
37
         filetype = ivle.mimetypes.DEFAULT_MIMETYPE
37
38
    return filetype
38
39
 
39
40
def throw_error(message, extra={}):
139
140
 
140
141
    print cjson.encode({'type': zip_mimetype,
141
142
                        'name': zipfilename})
142
 
    print zipfile.getvalue()
 
143
 
 
144
    stream = zipfile
 
145
    stream.seek(0)
143
146
else:
 
147
 
144
148
    print cjson.encode({'type': determine_file_type(filename),
145
149
                        'name': os.path.basename(filename)})
146
 
    print open(filename).read()
 
150
    stream = open(filename)
 
151
    
 
152
next = stream.read(1024)
 
153
while next:
 
154
    sys.stdout.write(next)
 
155
    next = stream.read(1024)