question about migrating from tg1 to tg1.5

2 views
Skip to first unread message

Daniel Fetchinson

unread,
Dec 27, 2010, 11:20:54 AM12/27/10
to turbogears
I'm using tg 1.5a1 and trying to migrate a project from tg1.1.

The document http://docs.turbogears.org/1.5/Upgrade was very useful,
thanks Chris!

After changing the configuration strings and changing a couple of
other things as described I can actually now start the server.

In the tg1.1 code I used Visits and now I've come across
http://docs.turbogears.org/1.5/VisitBasedSessions which kinda makes me
feel I need to add sessions.py as described. I'm using sqlobject by
the way. So these settings are there,

........
tools.sessions.on = True
tools.sessions.storage_type = 'visit'
visit.on=True
visit.timeout=60
.......


Now the question is whether I really need this sessions.py file? The
reason the whole issue came up is that whenever I access any URL I get
the traceback

Traceback (most recent call last):
File "/home/fetchinson/tmp/xxxx/lib/python2.6/site-packages/CherryPy-3.1.2-py2.6.egg/cherrypy/_cprequest.py",
line 603, in respond
self.hooks.run('before_handler')
File "/home/fetchinson/tmp/xxxx/lib/python2.6/site-packages/CherryPy-3.1.2-py2.6.egg/cherrypy/_cprequest.py",
line 98, in run
hook()
File "/home/fetchinson/tmp/xxxx/lib/python2.6/site-packages/CherryPy-3.1.2-py2.6.egg/cherrypy/_cprequest.py",
line 58, in __call__
return self.callback(**self.kwargs)
File "/home/fetchinson/tmp/xxxx/lib/python2.6/site-packages/TurboGears-1.5a1dev_r7146-py2.6.egg/turbogears/visit/api.py",
line 164, in __call__
False) and int(get('timeout', '20')) * 60 or None
TypeError: int() argument must be a string or a number, not 'dict'

As you can see I've set up a virtualenv in /home/fetchinson/tmp/xxxx

After looking around it turns out get('timeout', '20') at line 164 in
turbogears/visit/api.py is a dict, the entire configuration dict from
config/app.cfg. Is this normal? Is this the reason I need sessions.py
from the VisitBasedSessions docs?

Cheers,
Daniel


--
Psss, psss, put it down! - http://www.cafepress.com/putitdown

Christoph Zwerschke

unread,
Dec 31, 2010, 10:29:16 AM12/31/10
to turbo...@googlegroups.com
Am 27.12.2010 17:20 schrieb Daniel Fetchinson:
> In the tg1.1 code I used Visits and now I've come across
> http://docs.turbogears.org/1.5/VisitBasedSessions which kinda makes me
> feel I need to add sessions.py as described. I'm using sqlobject by
> the way.

That wiki page actually assumed SQLAlchemy, but I have added the
necessary code for SQLObject now as well (see last section).

> Now the question is whether I really need this sessions.py file? The
> reason the whole issue came up is that whenever I access any URL I get
> the traceback

For using CherryPy 3 sessions, you don't need the sessions.py file
posted on that wiki page. Just set tools.sessions.on = True and
tools.sessions.storage_type = 'ram' or 'file' and you're ready to go.

Only if you want to store your session data in the visit table, you
need the sessions.py file. Import it anywhere in your project to
activate it.

> After looking around it turns out get('timeout', '20') at line 164 in
> turbogears/visit/api.py is a dict, the entire configuration dict from
> config/app.cfg. Is this normal?

No, this should not happen. Something seems to be wrong with your
config. If you paste it somewhere or send it to me via mail I'll check.

> Is this the reason I need sessions.py from the VisitBasedSessions docs?

No, standard CherryPy sessions should work by just activating them in
the config.

-- Christoph

Reply all
Reply to author
Forward
0 new messages