562
by dcoles
Added new app: Diff (SVN diff application) |
1 |
# IVLE
|
2 |
# Copyright (C) 2007-2008 The University of Melbourne
|
|
3 |
#
|
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17 |
||
18 |
# App: Diff Service
|
|
19 |
# Author: David Coles
|
|
20 |
# Date: 21/2/2008
|
|
21 |
||
22 |
# This app is a wrapper around the diff script run through the trampoline
|
|
23 |
||
24 |
import os.path |
|
25 |
||
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
26 |
import ivle.conf |
27 |
import ivle.interpret |
|
562
by dcoles
Added new app: Diff (SVN diff application) |
28 |
|
29 |
||
30 |
# handle_with_trampoline controls the way in which fileservice_lib is invoked.
|
|
31 |
# If False, it will simply be called directly by this handler.
|
|
32 |
# If True, the request will get marshalled into a CGI environment and the
|
|
1072
by matt.giuca
Renamed scripts to services. |
33 |
# trampoline will invoke services/fileservices within the user's jail (SetUID'd
|
562
by dcoles
Added new app: Diff (SVN diff application) |
34 |
# to them). This script will then wrap the CGI environment in a replica of the
|
35 |
# original environment and handle it that way.
|
|
36 |
# This is a lot of overhead but it's the only way to properly ensure we are
|
|
37 |
# acting "as" that user and therefore we don't run into permissions problems.
|
|
38 |
# If set to True, it will be a lot more efficient, but there will be
|
|
39 |
# permissions issues unless all user's files are owned by the web server user.
|
|
40 |
HANDLE_WITH_TRAMPOLINE = True |
|
41 |
||
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
42 |
diffservice_path = os.path.join(ivle.conf.share_path, 'services/diffservice') |
562
by dcoles
Added new app: Diff (SVN diff application) |
43 |
|
44 |
def handle(req): |
|
45 |
"""Handler for the File Services application."""
|
|
46 |
req.styles = ["media/diff/diff.css"] # CSS styles |
|
47 |
req.write_html_head_foot = True # Have dispatch print head and foot |
|
48 |
||
49 |
# Handle
|
|
50 |
if not HANDLE_WITH_TRAMPOLINE: |
|
51 |
pass
|
|
52 |
else: |
|
53 |
if req.path == "": |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
54 |
req.throw_redirect(os.path.join(req.uri,req.user.login)); |
55 |
interp_object = ivle.interpret.interpreter_objects["cgi-python"] |
|
56 |
user_jail_dir = os.path.join(ivle.conf.jail_base, req.user.login) |
|
57 |
ivle.interpret.interpret_file(req, req.user.login, user_jail_dir, |
|
562
by dcoles
Added new app: Diff (SVN diff application) |
58 |
diffservice_path, interp_object) |
59 |