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

« back to all changes in this revision

Viewing changes to ivle/webapp/security/views.py

Port www/apps/logout to new framework (in ivle.webapp.security).

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
 
18
 
# App: Logout
19
 
# Author: Nick Chadwick
20
 
# Date: 13/01/2009
21
 
 
22
 
from ivle import util
23
 
 
24
 
import genshi
25
 
import genshi.template
26
 
 
27
 
# url path for this app
28
 
THIS_APP = "logout"
29
 
 
30
 
def handle(req):
31
 
    if req.method == "POST":
32
 
        req.logout()
33
 
    else:
34
 
        req.content_type = "text/html"
35
 
        req.write_html_head_foot = True
36
 
        ctx = genshi.template.Context()
37
 
        ctx['path'] =  util.make_path('logout')
38
 
        loader = genshi.template.TemplateLoader(".", auto_reload=True)
39
 
        tmpl = loader.load(util.make_local_path("apps/logout/template.html"))
40
 
        req.write(tmpl.generate(ctx).render('html')) #'xhtml', doctype='xhtml'))
 
18
# Author: Will Grant, Nick Chadwick
 
19
 
 
20
from ivle.webapp.base.xhtml import XHTMLView
 
21
import ivle.util
 
22
 
 
23
class LogoutView(XHTMLView):
 
24
    '''A view to log the current session out.'''
 
25
    template = 'logout.html'
 
26
 
 
27
    def populate(self, req, ctx):
 
28
        if req.method == "POST":
 
29
            req.logout()
 
30
        else:
 
31
            ctx['path'] =  ivle.util.make_path('logout')