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

« back to all changes in this revision

Viewing changes to services/serveservice

  • Committer: William Grant
  • Date: 2009-04-28 08:12:29 UTC
  • Revision ID: grantw@unimelb.edu.au-20090428081229-ofhimnm145ro20kt
Remove ivle.conf dependency from ivle.webapp.tutorial.service.

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
33
32
 
34
33
def determine_file_type(filename):
35
34
    filetype = mimetypes.guess_type(filename)[0]
36
35
    if filetype is None:
37
 
         filetype = ivle.mimetypes.DEFAULT_MIMETYPE
 
36
         filetype = ivle.conf.mimetypes.default_mimetype
38
37
    return filetype
39
38
 
40
39
def throw_error(message, extra={}):
112
111
    else:
113
112
        if not download and \
114
113
           determine_file_type(filename) in ivle.conf.app.server.interpreters:
115
 
            throw_error('is-executable', {'path': filename.decode('utf-8')})
 
114
            throw_error('is-executable', {'path': filename})
116
115
 
117
116
        if not download and (
118
117
            (ivle.conf.app.server.blacklist_served_filetypes and \
139
138
    zipmod.make_zip(zipbasepath, paths, zipfile)
140
139
 
141
140
    print cjson.encode({'type': zip_mimetype,
142
 
                        'name': zipfilename.decode('utf-8')})
 
141
                        'name': zipfilename})
143
142
 
144
143
    stream = zipfile
145
144
    stream.seek(0)
146
145
else:
147
146
 
148
147
    print cjson.encode({'type': determine_file_type(filename),
149
 
                        'name': os.path.basename(filename).decode('utf-8')})
 
148
                        'name': os.path.basename(filename)})
150
149
    stream = open(filename)
151
150
    
152
151
next = stream.read(1024)