On Dec 2, 2007, at 9:03 AM, [EMAIL PROTECTED] wrote:

>
> Hello, i have this code for pagination on my blog app ( cherrypy
> powered) (code is not complete) :
>
> http://www.pastebin.cz/show/2535
>
> I have problem, selecting/filtering by category_id is ok, but
> limit&offset making trouble.
> When i will next list with results, i get this error:
>
> ProgrammingError: SQLite objects created in a thread can only be used
> in that same thread.The object was created in thread id -1236735088
> and this is thread id -1253520496
>
> Is this problem with session or what ? Please help and sorry for my
> bad english.

what is probably happening is that you are assigning the "session" as  
an instance variable (i.e. self.session), and reusing the same Session  
in two different threads.  Since the Session is bound to a single  
sqlite connection, the same SQLite connection gets used in two  
different threads.  this is not supported by sqlite, but also the  
Session itself is not threadsafe either and is best used for only a  
single web request at a time.

your best bet with a web container like cherrypy is to use  
scoped_session so that you have a thread-local Session object.  With  
this pattern, you could keep the code you pasted more or less the  
same.   see the description at :  
http://www.sqlalchemy.org/docs/04/session.html#unitofwork_contextual 
  .


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to