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

« back to all changes in this revision

Viewing changes to src/apps/help/__init__.py

  • Committer: mattgiuca
  • Date: 2007-12-17 05:20:17 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:74
apps/help: Full help file handling (now this module works).
apps/dummy: Added help file.
common/util: Added make_local_path.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
# A sample / testing application for IVLE.
24
24
 
25
25
from common import util
 
26
import os
 
27
import conf
 
28
from conf import apps
 
29
 
 
30
# TODO: Nicer 404 errors
26
31
 
27
32
def handle(req):
28
33
    """Handler for the Help application."""
29
 
    # TODO
 
34
    (appurl, subpath) = util.split_path(req.path)
 
35
    # app must be valid and have help available
 
36
    if appurl not in conf.apps.app_url:
 
37
        req.throw_error(req.HTTP_NOT_FOUND)
 
38
    app = conf.apps.app_url[appurl]
 
39
    if not app.hashelp:
 
40
        req.throw_error(req.HTTP_NOT_FOUND)
 
41
    # subpath must be empty, for now, as there is only one help file per app
 
42
    if subpath != "":
 
43
        req.throw_error(req.HTTP_NOT_FOUND)
 
44
    helpfile = os.path.join(util.make_local_path("apps"), app.dir, "help.html")
30
45
 
31
46
    # Set request attributes
32
47
    req.content_type = "text/html"
33
 
    req.write_html_head_foot = True     # Have dispatch print head and foot
 
48
    req.write_html_head_foot = True
34
49
 
35
50
    # Start writing data
36
 
    req.write("<h1>Help</h1>\n")
 
51
    req.write("<h1>Help - %s</h1>\n" % app.name)
 
52
 
 
53
    # Print out the contents of the HTML help file
 
54
    req.sendfile(helpfile)