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

« back to all changes in this revision

Viewing changes to www/apps/server/__init__.py

  • Committer: drtomc
  • Date: 2008-03-05 22:53:07 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:657
serve: use the trampoline to serve all files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import os
32
32
import mimetypes
33
33
 
 
34
serveservice_path = "/opt/ivle/scripts/serveservice"
 
35
 
34
36
def handle(req):
35
37
    """Handler for the Server application which serves pages."""
36
38
    req.write_html_head_foot = False
101
103
    else:
102
104
        # Otherwise, use the blacklist/whitelist to see if this file should be
103
105
        # served or disallowed
104
 
        if conf.app.server.blacklist_served_filetypes:
105
 
            toserve = type not in conf.app.server.served_filetypes_blacklist
106
 
        else:
107
 
            toserve = type in conf.app.server.served_filetypes_whitelist
108
 
 
109
 
        # toserve or not toserve
110
 
        if not toserve:
 
106
        if (conf.app.server.blacklist_served_filetypes and \
 
107
                type in conf.app.server.served_filetypes_blacklist) or \
 
108
           (conf.app.server.served_filetypes_whitelist and \
 
109
                type not in conf.app.server.served_filetypes_whitelist): 
111
110
            req.throw_error(req.HTTP_FORBIDDEN,
112
111
                "Files of this type are not allowed to be served.")
113
 
        else:
114
 
            serve_file_direct(req, filename, type)
 
112
 
 
113
        interp_object = interpret.interpreter_objects["cgi-python"]
 
114
        user_jail_dir = os.path.join(conf.jail_base, req.user.login)
 
115
        interpret.interpret_file(req, req.user.login, user_jail_dir,
 
116
            serveservice_path, interp_object)
115
117
 
116
118
def serve_file_direct(req, filename, type):
117
119
    """Serves a file by directly writing it out to the response.