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

« back to all changes in this revision

Viewing changes to scripts/svnlogservice

  • Committer: mattgiuca
  • Date: 2008-02-19 08:26:11 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:509
common.db: Rewrote user_authenticate to return 3 values (True, false, None)
    Now returns False if the password did not match, None if the password
    field is NULL (None implying a soft failure, with the possibility of
    validating against LDAP or something else).

auth.authenticate: Rewrote this module with a new plugin interface
    (as discussed with Tom Conway). Allows successive modules to try to
    authenticate the user.
    Changed the authenticate function interface: Now raises an AuthError
    when auth fails, instead of returning None.

dispatch.login: Handle new auth interface (exception catch).
    Auth is now able to provide an error message, in the exception.
    The exception message is displayed as an error to the user.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
3
 
# IVLE - Informatics Virtual Learning Environment
4
 
# Copyright (C) 2008 The University of Melbourne
5
 
#
6
 
# This program is free software; you can redistribute it and/or modify
7
 
# it under the terms of the GNU General Public License as published by
8
 
# the Free Software Foundation; either version 2 of the License, or
9
 
# (at your option) any later version.
10
 
#
11
 
# This program is distributed in the hope that it will be useful,
12
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
# GNU General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program; if not, write to the Free Software
18
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 
20
 
# Script: logservice
21
 
# Author: William Grant
22
 
# Date:   08/07/2008
23
 
 
24
 
# A CGI script for viewing a Subversion log. Used by the svnlog app.
25
 
 
26
 
import os
27
 
import time
28
 
import pysvn
29
 
 
30
 
from common import cgirequest
31
 
 
32
 
req = cgirequest.CGIRequest()
33
 
req.install_error_handler()
34
 
req.content_type = "text/html"
35
 
 
36
 
req.write('<h1>Subversion Log</h1>\n')
37
 
 
38
 
 
39
 
def pretty_time(epochtime):
40
 
    return time.asctime(time.localtime(epochtime))
41
 
 
42
 
def pretty_path(path):
43
 
    return '%s %s' % (path['action'], path['path'])
44
 
 
45
 
def pretty_paths(paths):
46
 
    output = '<ul>'
47
 
    for path in paths:
48
 
        output += '<li>' + pretty_path(path) + '</li>'
49
 
    output += '</ul>'
50
 
    return output
51
 
 
52
 
def pretty_log(log):
53
 
    return '''
54
 
<div class="svnlogentry">
55
 
        <div class="svnloginfo">
56
 
                Revision <strong>%d</strong> by <strong>%s</strong> on <strong>%s</strong>
57
 
        </div>
58
 
        <pre>%s</pre>
59
 
        <hr size="1"/>
60
 
        <h2>Changed paths:</h2>
61
 
        <div class="svnlogpathlist">
62
 
        %s
63
 
        </div>
64
 
</div>''' % (log.revision.number, log.author, pretty_time(log.date),
65
 
             log.message, pretty_paths(log.changed_paths))
66
 
 
67
 
try:
68
 
    client = pysvn.Client()
69
 
    logs = client.log(os.path.join('/home', req.path), discover_changed_paths=True)
70
 
    [req.write(pretty_log(log)) for log in logs]
71
 
except pysvn.ClientError, e:
72
 
    req.write('<p><b>Error:</b></p>\n')
73
 
    req.write('<pre>%s</pre>\n' % cgi.escape(str(e)))