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

« back to all changes in this revision

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

ivle.webapp.filesystem.diff: Add some docstrings, and remove a constant which was only used in one place.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
# Author: David Coles, Will Grant
19
19
 
 
20
'''Components of the webapp for diffing user files.'''
 
21
 
20
22
import os
21
23
import re
22
24
import cgi
30
32
from ivle.webapp.base.plugins import BasePlugin
31
33
from ivle.webapp.errors import NotFound, BadRequest
32
34
 
33
 
diffservice_path = os.path.join(ivle.conf.share_path, 'services/diffservice')
34
 
 
35
35
class DiffView(XHTMLView):
 
36
    '''A view to present a nice XHTML Subversion diff from a user's jail.'''
36
37
    template = 'template.html'
37
38
 
 
39
    def __init__(self, req, path):
 
40
        self.path = path
 
41
 
38
42
    def populate(self, req, ctx):
39
43
        req.styles = ["/media/diff/diff.css"] # CSS styles
40
44
 
44
48
 
45
49
        revs = [revfield.value for revfield in revfields]
46
50
 
47
 
        user_jail_dir = os.path.join(ivle.conf.jail_base, req.user.login)
48
 
        (out, err) = ivle.interpret.execute_raw(req.user, user_jail_dir,
49
 
                                 '/home', diffservice_path, [self.path] + revs)
 
51
        jail_dir = os.path.join(ivle.conf.jail_base, req.user.login)
 
52
        (out, err) = ivle.interpret.execute_raw(req.user, jail_dir, '/home',
 
53
                    os.path.join(ivle.conf.share_path, 'services/diffservice'),
 
54
                    [self.path] + revs)
50
55
        assert not err
51
56
 
52
57
        response = cjson.decode(out)
93
98
    return '<pre class="diff">%s</pre>' % output
94
99
 
95
100
class Plugin(BasePlugin):
 
101
    '''Registration class for diff components.'''
96
102
    urls = [
97
103
        ('diff/', DiffView, {'path': ''}),
98
104
        ('diff/*(path)', DiffView),