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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-01-13 01:36:15 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1123
Merge setup-refactor branch. This completely breaks existing installations;
every path (both filesystem and Python) has changed. Do not upgrade without
knowing what you are doing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
 
40
40
import cjson
41
41
 
42
 
from common import util
43
 
import conf
44
 
import common.db
 
42
from ivle import util
 
43
import ivle.conf
 
44
import ivle.db
45
45
 
46
46
from rst import rst
47
47
 
124
124
    if urlpath.startswith("..") or urlpath.startswith('/'):
125
125
        req.throw_error(req.HTTP_FORBIDDEN,
126
126
            "Invalid path.")
127
 
    filename = os.path.join(conf.subjects_base, urlpath)
 
127
    filename = os.path.join(ivle.conf.subjects_base, urlpath)
128
128
    (type, _) = mimetypes.guess_type(filename)
129
129
    if type is None:
130
 
        type = conf.mimetypes.default_mimetype
 
130
        type = ivle.conf.mimetypes.default_mimetype
131
131
    ## THIS CODE taken from apps/server/__init__.py
132
132
    if not os.access(filename, os.R_OK):
133
133
        req.throw_error(req.HTTP_NOT_FOUND,
151
151
  for that subject.</p>\n""")
152
152
 
153
153
    (enrolled_subjects, unenrolled_subjects) = \
154
 
              common.db.DB().get_subjects_status(req.user.login)
 
154
              ivle.db.DB().get_subjects_status(req.user.login)
155
155
 
156
156
    def print_subject(subject):
157
157
        req.write('  <li><a href="%s">%s</a></li>\n'
189
189
    # The subject directory must have a file "subject.xml" in it,
190
190
    # or it does not exist (404 error).
191
191
    try:
192
 
        subjectfile = open(os.path.join(conf.subjects_base, subject,
 
192
        subjectfile = open(os.path.join(ivle.conf.subjects_base, subject,
193
193
            "subject.xml"))
194
194
    except:
195
195
        req.throw_error(req.HTTP_NOT_FOUND,
213
213
                worksheetdom.getAttribute("assessable") == "true")
214
214
            worksheets.append(worksheet)
215
215
 
216
 
    db = common.db.DB()
 
216
    db = ivle.db.DB()
217
217
    try:
218
218
        # Now all the errors are out the way, we can begin writing
219
219
        req.title = "Tutorial - %s" % subject
258
258
                            'Completed %d/%d%s</li></ul>\n  '
259
259
                            % (complete_class, mand_done, mand_total,
260
260
                                optional_message))
261
 
            except common.db.DBException:
 
261
            except ivle.db.DBException:
262
262
                # Worksheet is probably not in database yet
263
263
                pass
264
264
            req.write('</li>\n')
293
293
                % (repr(subject), repr(worksheet)))
294
294
 
295
295
    # Read in worksheet data
296
 
    worksheetfilename = os.path.join(conf.subjects_base, subject,
 
296
    worksheetfilename = os.path.join(ivle.conf.subjects_base, subject,
297
297
            worksheet + ".xml")
298
298
    try:
299
299
        worksheetfile = open(worksheetfilename)
352
352
<h2>Worksheet Contents</h2>
353
353
<ul>
354
354
""")
355
 
    db = common.db.DB()
 
355
    db = ivle.db.DB()
356
356
    try:
357
357
        for tag, xml in find_all_nodes(req, node):
358
358
            if tag == "ex":
520
520
    # If the user has already saved some text for this problem, or submitted
521
521
    # an attempt, then use that text instead of the supplied "partial".
522
522
    saved_text = None
523
 
    db = common.db.DB()
 
523
    db = ivle.db.DB()
524
524
    try:
525
525
        saved_text = db.get_problem_stored_text(login=req.user.login,
526
526
            exercisename=exercisesrc)
625
625
    the existing data. If the worksheet does not yet exist, and assessable
626
626
    is omitted, it defaults to False.
627
627
    """
628
 
    db = common.db.DB()
 
628
    db = ivle.db.DB()
629
629
    try:
630
630
        db_mtime = db.get_worksheet_mtime(subject, worksheet)
631
631
        if db_mtime is None or file_mtime > db_mtime: