sessions in juno

12 views
Skip to first unread message

axh...@gmail.com

unread,
Mar 24, 2009, 5:44:29 PM3/24/09
to juno-framework
Hi,

I am testing the session in juno. I tried the example below but am not
able to get it working. Is there something I am missing?

Ashish
------------------
Code used:
from juno import *

init({'dev_port':8080, 'use_templates':False})
@get('/foo/')
def foo(web):
web.session['msg'] = 'hello there'
web.session.save()
redirect('/bar/')

@get('/bar/')
def bar(web):
return web.session['msg']

run()

----------------

Stack trace:
GET request for /foo/...
/foo/ matches, calling foo()...

Error: (<type 'exceptions.TypeError'>, 'NoneType' object does not
support item assignment, <traceback object at 0x913ac0c>)
Traceback (most recent call last):
File "/usr/lib/python2.6/wsgiref/handlers.py", line 93, in run
self.result = application(self.environ, self.start_response)
File "/home/a/app/juno.py", line 724, in application
**environ)
File "/home/a/app/juno.py", line 200, in request
return servererror(error=cgi.escape(str(sys.exc_info()))).render()
File "/home/a/app/juno.py", line 506, in servererror
return template(file, error=error)
File "/home/a/app/juno.py", line 543, in template
t = get_template(template_path)
File "/home/a/app/juno.py", line 557, in get_template
return config('get_template_handler')(template_path)
File "/home/a/app/juno.py", line 565, in _get_template_handler
return config('template_env').get_template(template_path)
AttributeError: 'NoneType' object has no attribute 'get_template'
localhost.localdomain - - [24/Mar/2009 15:36:43] "GET /foo/ HTTP/1.0"
500 59

Andras Biczo

unread,
Mar 24, 2009, 6:16:50 PM3/24/09
to juno-framework
Sessions are disabled by default, so you'll need to add
"'use_sessions': True" to the init() parameters.

Brian

unread,
Mar 24, 2009, 6:21:13 PM3/24/09
to juno-framework
You'll need to add {'use_sessions': True} to your init() call (they're
disabled by default, and web.sessions is set to None if they're not
enabled). You'll need Beaker (http://wiki.pylonshq.com/display/beaker/
Home) to use them.

Brian

axh...@gmail.com

unread,
Mar 24, 2009, 6:59:29 PM3/24/09
to juno-framework
Thanks for all the replies. Progressed further but still get

/bar/ matches, calling bar()...

Error: (<type 'exceptions.KeyError'>, 'msg', <traceback object at
0x8454e64>)
Traceback (most recent call last):
File "/usr/lib/python2.6/wsgiref/handlers.py", line 93, in run
self.result = application(self.environ, self.start_response)
File "/usr/lib/python2.6/site-packages/Beaker-1.2.3-py2.6.egg/beaker/
middleware.py", line 160, in __call__
return self.wrap_app(environ, session_start_response)

Brian

unread,
Mar 24, 2009, 7:31:44 PM3/24/09
to juno-framework
Hmm... are you going to /bar/ before you go to /foo/? That's the only
way I've managed to get that error with your code.

axh...@gmail.com

unread,
Mar 25, 2009, 1:55:38 AM3/25/09
to juno-framework
No, I am doing /foo/, I get redirect to /bar/ and I get the error.

running Juno development server, <C-c> to exit...
connect to 127.0.0.1:8090 to use your app...

GET request for /foo/...
/foo/ matches, calling foo()...

192.168.1.4 - - [24/Mar/2009 23:52:09] "GET /foo/ HTTP/1.1" 302 0
GET request for /bar/...
/bar/ matches, calling bar()...

Error: (<type 'exceptions.KeyError'>, 'msg', <traceback object at
0x8d96324>)
Traceback (most recent call last):
File "/usr/lib/python2.6/wsgiref/handlers.py", line 93, in run
self.result = application(self.environ, self.start_response)
File "/usr/lib/python2.6/site-packages/Beaker-1.2.3-py2.6.egg/beaker/
middleware.py", line 160, in __call__
return self.wrap_app(environ, session_start_response)
File "/home/ashish/test/juno.py", line 724, in application
**environ)
File "/home/ashish/test/juno.py", line 200, in request
return servererror(error=cgi.escape(str(sys.exc_info()))).render()
File "/home/ashish/test/juno.py", line 506, in servererror
return template(file, error=error)
File "/home/ashish/test/juno.py", line 543, in template
t = get_template(template_path)
File "/home/ashish/test/juno.py", line 557, in get_template
return config('get_template_handler')(template_path)
File "/home/ashish/test/juno.py", line 565, in _get_template_handler
return config('template_env').get_template(template_path)
AttributeError: 'NoneType' object has no attribute 'get_template'
192.168.1.4 - - [24/Mar/2009 23:52:09] "GET /bar/ HTTP/1.1" 500 59

I am on
Linux getafix 2.6.28-ARCH #1 SMP PREEMPT Sun Feb 22 11:03:50 UTC 2009
i686 AMD Athlon(tm) XP 2400+ AuthenticAMD GNU/Linux

Python 2.6.1 (r261:67515, Dec 7 2008, 08:27:41)
[GCC 4.3.2] on linux2


And using Beaker-1.2.3


Is there anything I can test or do to debug this issue?

Ashish

axh...@gmail.com

unread,
Mar 25, 2009, 3:22:29 AM3/25/09
to juno-framework
Hi Brian,

Sorry, it was all my mistake. I selectively allow cookies in my
browser and had forgotten to allow cookies for the domain. Things work
fine now.

Ashish
Reply all
Reply to author
Forward
0 new messages