Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #779: auth_session_conflict.py

Line 
1 import cherrypy
2
3 conf = {
4         '/': {
5             'tools.sessions.on':True,
6             }
7         }
8
9 def inc_counter():
10     v = cherrypy.session.get('count', 0)
11     cherrypy.session['count'] = v + 1
12     return v
13
14 class App(object):
15     @cherrypy.expose
16     def index(self):
17         return """
18         You have been here %s time(s)<br />\n
19         <a href="enable_auth">Enable Basic Auth</a>
20         """ % inc_counter()
21
22     @cherrypy.expose
23     def enable_auth(self):
24         aconf = {
25                 '/': {
26                     'tools.digest_auth.on':True,
27                     'tools.digest_auth.realm':'localhost',
28                     'tools.digest_auth.users':{'test':'test'},
29                     }
30                 }
31         cherrypy.request.app.merge(aconf)
32         return """
33         Auth enabled!<br />\n
34         <a href="/">Home</a>
35         """
36
37
38 cherrypy.quickstart(App(), '/', conf)
39
40

Hosted by WebFaction

Log in as guest/cpguest to create tickets