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

« back to all changes in this revision

Viewing changes to ivle/webapp/base/xhtml.py

ivle.chat now closes all file descriptors when daemonising.

This lets usrmgt-server not break postinsts, but more importantly stops
python-console from breaking Apache. Yes, that's finally fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        for key in kwargs:
49
49
            setattr(self, key, kwargs[key])
50
50
 
51
 
    def filter(self, stream, ctx):
52
 
        return stream
53
 
 
54
51
    def render(self, req):
55
52
        req.content_type = 'text/html' # TODO: Detect application/xhtml+xml
56
53
 
64
61
                        inspect.getmodule(self).__file__), self.template) 
65
62
        loader = genshi.template.TemplateLoader(".", auto_reload=True)
66
63
        tmpl = loader.load(app_template)
67
 
        app = self.filter(tmpl.generate(viewctx), viewctx)
 
64
        app = tmpl.generate(viewctx)
68
65
 
69
66
        for plugin in self.plugin_scripts:
70
67
            for path in self.plugin_scripts[plugin]:
77
74
        # Global template
78
75
        ctx = genshi.template.Context()
79
76
        # XXX: Leave this here!! (Before req.styles is read)
80
 
        ctx['overlays'] = self.render_overlays(req) if req.user else []
 
77
        ctx['overlays'] = self.render_overlays(req)
81
78
 
82
79
        ctx['styles'] = [media_url(req, CorePlugin, 'ivle.css')]
83
80
        ctx['styles'] += req.styles
84
81
 
85
82
        ctx['scripts'] = [media_url(req, CorePlugin, path) for path in
86
83
                           ('util.js', 'json2.js', 'md5.js')]
87
 
        ctx['scripts'].append(media_url(req, '+external/jquery', 'jquery.js'))
88
84
        ctx['scripts'] += req.scripts
89
85
 
90
86
        ctx['scripts_init'] = req.scripts_init
91
87
        ctx['app_template'] = app
92
 
        ctx['title_img'] = media_url(req, CorePlugin,
93
 
                                     "images/chrome/title.png")
94
88
        self.populate_headings(req, ctx)
95
89
        tmpl = loader.load(os.path.join(os.path.dirname(__file__), 
96
90
                                                        'ivle-headings.html'))
123
117
            for tab in plugin.tabs:
124
118
                # tab is a tuple: name, title, desc, icon, path
125
119
                new_app = {}
126
 
                new_app['this_app'] = hasattr(self, 'tab') \
127
 
                                      and tab[0] == self.tab
 
120
                new_app['this_app'] = hasattr(self, 'appname') \
 
121
                                      and tab[0] == self.appname
128
122
 
129
123
                # Icon name
130
124
                if tab[3] is not None:
197
191
 
198
192
        if req.user is None:
199
193
            # Not logged in. Redirect to login page.
200
 
            if req.uri == '/':
201
 
                query_string = ''
202
 
            else:
203
 
                query_string = '?url=' + urllib.quote(req.uri, safe="/~")
204
 
            req.throw_redirect('/+login' + query_string)
 
194
            req.throw_redirect('/+login?' + 
 
195
                               urllib.urlencode([('url', req.uri)]))
205
196
 
206
197
        req.status = 403