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

« back to all changes in this revision

Viewing changes to lib/common/util.py

  • Committer: mattgiuca
  • Date: 2008-03-09 13:58:10 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:675
remakeallusers: Removed bogus return statement at the top level.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
root_dir = conf.root_dir
33
33
 
 
34
class IVLEError(Exception):
 
35
    """
 
36
    This is the "standard" exception class for IVLE errors.
 
37
    It is the ONLY exception which should propagate to the top - it will then
 
38
    be displayed to the user as an HTTP error with the given code.
 
39
 
 
40
    All other exceptions are considered IVLE bugs and should not occur
 
41
    (they will display a traceback).
 
42
 
 
43
    This error should not be raised directly. Call req.throw_error.
 
44
    """
 
45
    def __init__(self, httpcode, message=None):
 
46
        self.httpcode = httpcode
 
47
        self.message = message
 
48
        self.args = (httpcode, message)
 
49
 
34
50
def make_path(path):
35
51
    """Given a path relative to the IVLE root, makes the path relative to the
36
52
    site root using conf.root_dir. This path can be used in URLs sent to the
118
134
                return filename[filename.rindex('.')+1:].upper() + " file"
119
135
            except ValueError:
120
136
                return "File"
 
137
 
 
138
def send_terms_of_service(req):
 
139
    """
 
140
    Sends the Terms of Service document to the req object.
 
141
    This consults conf to find out where the TOS is located on disk, and sends
 
142
    that. If it isn't found, it sends a generic message explaining to admins
 
143
    how to create a real one.
 
144
    """
 
145
    try:
 
146
        req.sendfile(conf.tos_path)
 
147
    except IOError:
 
148
        req.write(
 
149
"""<h1>Terms of Service</h1>
 
150
<p><b>*** SAMPLE ONLY ***</b></p>
 
151
<p>This is the text of the IVLE Terms of Service.</p>
 
152
<p>The administrator should create a license file with an appropriate
 
153
"Terms of Service" license for your organisation.</p>
 
154
<h2>Instructions for Administrators</h2>
 
155
<p>You are seeing this message because you have not configured a Terms of
 
156
Service document.</p>
 
157
<p>When you configured IVLE, you specified a path to the Terms of Service
 
158
document (this is found in <b><tt>lib/conf/conf.py</tt></b> under
 
159
"<tt>tos_path</tt>").</p>
 
160
<p>Create a file at this location; an HTML file with the appropriately-worded
 
161
license.</p>
 
162
<p>This should be a normal XHTML file, except it should not contain
 
163
<tt>html</tt>, <tt>head</tt> or <tt>body</tt> elements - it should
 
164
just be the contents of a body element (IVLE will wrap it accordingly).</p>
 
165
<p>This will automatically be used as the license text instead of this
 
166
placeholder text.</p>
 
167
""")