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

« back to all changes in this revision

Viewing changes to src/dispatch/__init__.py

  • Committer: mattgiuca
  • Date: 2007-12-12 06:04:10 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:45
Added actual app handlers for dummy and help.
Added module apps/__init__, which provides a function to load and execute
applications.
dispatch: Moved test_handler into apps/dummy. Now calls apps to actually load
the requested application!

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
import os.path
34
34
import conf
35
35
import conf.apps
 
36
import apps
36
37
 
37
38
from request import Request
38
39
import html
69
70
        mod_python.util.redirect(apachereq, util.make_path(conf.default_app))
70
71
 
71
72
    # Call the specified app with the request object
72
 
    # TODO: Call a real app.
73
 
    test_app(req)
 
73
    apps.call_app(app.dir, req)
74
74
 
75
75
    # When done, write out the HTML footer if the app has requested it
76
76
    if req.write_html_head_foot:
82
82
    # Have Apache output its own HTML code if non-200 status codes were found
83
83
    return req.status
84
84
 
85
 
def test_app(req):
86
 
    """This (temporary) function serves as an IVLE application. It takes an
87
 
    IVLE request and conforms to the application API."""
88
 
    # TEMP: Dummy (test) handler
89
 
 
90
 
    # Set request attributes
91
 
    req.content_type = "text/html"
92
 
    req.write_html_head_foot = True     # Have dispatch print head and foot
93
 
 
94
 
    # Start writing data
95
 
    req.write("<p>Hello, IVLE!</p>\n")
96
 
    req.write('<p>')
97
 
    if req.app == None:
98
 
        req.write('<b>No app specified</b>')
99
 
    else:
100
 
        req.write('<b>' + req.app + '</b> ')
101
 
        req.write('<img src="' + util.make_path("media/images/mime/dir.png")
102
 
            + '" /> ')
103
 
        req.write(str(req.path))
104
 
    req.write("</p>\n")
105
 
 
106
 
    print_apps_list(req)
107
 
 
108
85
def print_apps_list(file):
109
86
    """Prints all app tabs, as a UL. Prints a list item for each app that has
110
87
    a tab.