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

« back to all changes in this revision

Viewing changes to services/serveservice

  • Committer: Nick Chadwick
  • Date: 2009-03-17 01:42:19 UTC
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090317014219-e0dvzakaxw58b71p
Fixed a problem with exercise editor, which wasn't editing or adding
variables properly.

Fixed the final issues from the merge-proposal, which make deleting
exercises use appropriate functions, which now raise exceptions
if they fail.

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={}):
140
139
 
141
140
    print cjson.encode({'type': zip_mimetype,
142
141
                        'name': zipfilename})
143
 
 
144
 
    stream = zipfile
145
 
    stream.seek(0)
 
142
    print zipfile.getvalue()
146
143
else:
147
 
 
148
144
    print cjson.encode({'type': determine_file_type(filename),
149
145
                        'name': os.path.basename(filename)})
150
 
    stream = open(filename)
151
 
    
152
 
next = stream.read(1024)
153
 
while next:
154
 
    sys.stdout.write(next)
155
 
    next = stream.read(1024)
 
146
    print open(filename).read()