[Zope3-dev] Database Transaction Handling

Axel Missbach Axel.Missbach@t-online.de
Fri, 01 Nov 2002 17:56:47 +0100


Jim Fulton wrote:
> Axel Missbach wrote:
> 
>> Hello,
>>
>> in my opinion a great handicap of zope2 is occuping the 
>> database-transaction for the kommunikation  of documents and extern 
>> databases(i.e. postgres).
>>
>>     implicit start transaction to database
>>     opening document
>>     .
>>     .
>>     .
>>     close document
>>     implicit commit/close transaction to database
>>
>> There is no transaction left to handle the querys/ data of the database.
> 
> 
> I don't follow you. Everything Zope does is in one transaction that
> affects ZODB and relational databases together.
yes, exactly there is my problem. from the point of zope eyerything is 
fine, the ZODB gets the commit but the effected data in the postgres 
database doesn't have to be ok. but it gets the commit too.
> 
> 
>> What about of explizit using the transaction handling by the 
>> user/developer?
> 
> 
> This is possible now. In Zope 2, just:
> 
>   get_transaction().commit()
> 
> to commit. There are similar calls to abort or even begin.
> Beginning a transaction aborts any already started transactions.
> 
> 
>> Isn't it possible to create an zope intern transaction handling 
>> without interacting with the database?
> 
> 
> I don't know what "create an zope intern transaction handling" means.
> 
> 
>  > Implementing something like
> 
>> triggers/events for documents,
> 
> 
> I don't know what this would mean.
> 
> 
>  > so having the possibility to change the
> 
>> default behavior?
>> i'd like to handle the database transaction like this:
>>
>>     opening document
>>     sql_query starts transaction
>>     sql_query gets data
>>     doing something
>>     .
>>     deciding if commit or rollback the querys
>>     closing document
> 
> 
> What do you mean by "document"?  You don't open or close objects
> commonly refered to as documents in Zope 2, so I don't think I
> have any idea what you are refering to.
> 
> Jim
> 

Trying to develop an application using zope and postgres, there is my 
problem, that zope occupies the transaction to postgres. It is not a 
problem of the internal handling of zope and ZODB, but of sending the 
commit to postgres by closing the dtml-document/sql_query. (I think 
there is no way to suppress it)
Closing an dtml-document with a query to postgres, zope sends the commit 
to postgres if there is no zope error.
There is no way in rolling back the data changes if annother (a 
following one) dtml-document/ function wants to decide to, because zope 
has already commited the changes.

Postgres does not support nested transactions yet(until 7.3), so it is 
not possible to open another transaction.

In other environments the usual way is:(in brackets the zope behavior)
  -start transaction to postgres
  -reading data (opening 1. dtml-document, something like a browser)
  -manipulation data (opening 2. dtml-document, something like a dialogbox).
  -submit the Dialog.
  -the dialog is closed(!!zope send the commit to postgres!!)
  -check the changes(opening 3. dtml-document or python-function) and 
perhaps want to rollback the data changes.(which is no longer possible 
because of zopes earlier comittment)
  -rolling back or commit the transaction.

Axel