Very Strange problem with Z SQL or ??
I use this structure ZPT -> Python Script -> Z SQL I create a new object in the database (pg). First I do the nextval dance. I get the correct ID back. Armed with this ID I insert my data. Data is correct inserted. Now I use the ID to select data from the DB, so the user can see the object created. This Z SQL object works perfectly when I test it. But when I use it in my python script - it returns empty every second time!? That is first it returns empty, but if I refresh the page once more the correct data is displayed. My first idea was that the browser cached the pages - but this is not the case. I can test this by printing the object_id on the page. No caching done here. If I in the python script hard code a object_id this object is returned correctly. With this notion in mind I started testing the value of object_id just before I call the Z SQL object. object_id != None and object_id != '' and object_id > 0 object_id is an integer greater than 0. So what do I do now? Any suggestions? Need more information? Thanks for your time.. \Oliver
Oliver Marx writes:
.... Now I use the ID to select data from the DB, so the user can see the object created. This Z SQL object works perfectly when I test it. But when I use it in my python script - it returns empty every second time!?
That is first it returns empty, but if I refresh the page once more the correct data is displayed. Indeed strange. Looks like a synchronization problem:
Are the creation of the id and your Python Script call related in some way: e.g. done in different requests (transactions) at about the same time? Then, it would be possible that the Python Scripts still sees old state. Another potential problem: Maybe, your DA (database adapter) uses connection pooling and assigns one connection to the id creation and a different one to the script (this would be a bug!). In this case, too, the Python script would see stale state. After the commit at the end of the request, everything would be ok again. Dieter
participants (2)
-
Dieter Maurer -
Oliver Marx