1) Create your table:

CREATE TABLE session (
     id varchar(40),
     data text,
     expiration_time timestamp
);


2) Set:

session_filter.on = True
session_filter.storage_type = "PostgreSQL"

in your .cfg file

2) Inside your controllers.py, (or any file that get's imported, you  
need to make sure it runs before any request) set:

turbogears.config.update({'session_filter.get_db':get_db_for_sessions})

where get_db_for_sessions is a function that returns a connecction  
object to your DB (sorry, no TG hubs here, needs to be a psycopg  
conn. object. Something like:

def get_db_for_sessions():
     import psycopg2
     dsn = config.get('postgres.dsn')
     return psycopg2.connect(dsn)

(you need a line at your .cf file like this:
postgres.dsn="dbname = db user=user password=passwd host=host")

This should get you started... The rest of the config options are  
common to all the session storage backends.

HTH, Alberto

On 12/04/2006, at 13:11, <[EMAIL PROTECTED]>  
<[EMAIL PROTECTED]> wrote:

>
>
> Can anyone point me to some info on using the database backend for  
> CherryPy sessions within TurboGears?
>
> I've done a bit of googling and looked at the CherryPy docs but I'm  
> wondering if there's a TurboGears API layer for setting it up  
> (config file specification etc).
>
> Cheers,
>
> Justin
>
>
> -----------------------------------------
> Email sent from www.ntlworld.com
> Virus-checked using McAfee(R) Software
> Visit www.ntlworld.com/security for more information
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to