[mod_python] Lock-Problem with Oracle

Sean Allen sean at ardishealth.com
Fri Mar 14 12:06:22 EDT 2008


On Mar 14, 2008, at 9:16 AM, Hartmut Fröls wrote:

> Hi Group,
>
> I try to use mod_python to generate a browser-based GUI for a
> small ERP-Application.
> I use Apache 2.2, mod_python 3.3.1 and Python 2.4.4  with Oracle 9i2.
>
> At first I wrote a programm  like this:
>
> ########################################
> import db      # my database handlers with cx_Oracle
>
> def index(req):
>
>   ...               # generate a http-page with a form
>
>   return http
>
> def GetDat(req,**data):
>      .....
>      db.select(...... for_update=1)
>      .....
>      return data
>
> def PutDat(req,**data):
>      .....
>      db.update(data)
>      .....
>      return succes
>
> #########################################
>
> The http-page has some AJAX-functions, which send and recieve
> the datas the user needs or has updatet.
>
> The problem is, when the programm makes the update on the
> database, it waits for the lock, because the programm has opend
> a second cursor for the update, although the cursor-objects should
> be global. I know, after reading many of the postings in this group  
> and all over
> the web, that this is because mod_python opens a new request for
> the call of the PutDat() function and this new interpreter-instance of
> this request has its own global vars.
> So I come to my question: is there any way to tell mod_python, that  
> the
> AJAX-request from the http-page must go to the interpreter-instance,
> that has generatet the page ?  Or do You know any other solution for
> this lock-problem ?
>

Let me see if I follow this:

index is called
getDat is called
putDat is called via ajax.

why exactly is a lock being held after getDat?
are you locking it explicitly in getDat? if yes, when exactly would  
that lock be released?

if you are locking it, then basically you are trying to do something  
stateful via a stateless
medium which is going to cause you a large amount of trouble.

I suggest if the above is the case, you look into 'optimistic locking':

http://en.wikipedia.org/wiki/Optimistic_concurrency_control








More information about the Mod_python mailing list