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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-02-17 05:06:35 UTC
  • mto: (1099.1.143 new-dispatch)
  • mto: This revision was merged to the branch mainline in revision 1100.
  • Revision ID: grantw@unimelb.edu.au-20090217050635-9u85hgrreg9flp2h
Remove interpretservice, and clean up ivle.webapp.filesystem.serve.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
# our safe execution environment.
26
26
 
27
27
import os
28
 
import mimetypes
29
28
 
30
29
import cjson
31
30
 
32
 
from ivle import (util, studpath, interpret)
 
31
from ivle import (studpath, interpret)
33
32
import ivle.conf
34
33
from ivle.database import User
35
34
from ivle.webapp.base.views import BaseView
36
35
from ivle.webapp.base.plugins import ViewPlugin
37
36
from ivle.webapp.errors import NotFound, Unauthorized, Forbidden
38
37
 
39
 
serveservice_path = os.path.join(ivle.conf.share_path, 'services/serveservice')
40
 
interpretservice_path = os.path.join(ivle.conf.share_path,
41
 
                                     'services/interpretservice')
42
 
 
43
 
# Serve all files as application/octet-stream so the browser presents them as
44
 
# a download.
45
 
default_mimetype = "application/octet-stream"
46
 
zip_mimetype = "application/zip"
47
 
 
48
38
class ServeView(BaseView):
49
39
    def __init__(self, req, path):
50
40
        self.path = path
111
101
    # We need a no-op trampoline run to ensure that the jail is mounted.
112
102
    # Otherwise we won't be able to authorise for public mode!
113
103
    noop_object = interpret.interpreter_objects["noop"]
114
 
    user_jail_dir = os.path.join(ivle.conf.jail_base, owner.login)
115
 
    interpret.interpret_file(req, owner, user_jail_dir, '', noop_object)
 
104
    interpret.interpret_file(req, owner, jail, '', noop_object)
116
105
 
117
106
    # Authorize access. If failure, this throws a HTTP_FORBIDDEN error.
118
107
    if not authorize(req):
143
132
        elif response['error'] in ('is-directory', 'forbidden'):
144
133
            raise Forbidden()
145
134
        elif response['error'] == 'is-executable':
146
 
            # We need to ask interpretservice to execute it.
 
135
            # We need to execute it. Just run it with Python in the jail.
147
136
            interp_object = interpret.interpreter_objects["cgi-python"]
148
137
            interpret.interpret_file(req, owner, jail, response['path'],
149
138
                                     interp_object, gentle=True)