Re: [Zope] Forcing Zope transaction commit

2005-07-19 Thread Bakhtiar A Hamid
On 7/19/05, David H [EMAIL PROTECTED] wrote:
 Hi list,
 
 At times (it seems)  necessary to force a Zope transaction commit.  This
 might occur between two zSQL calls where the second depends on the
 first's *SQL* transaction's availability but the first has not yet been
 commited because the *Zope* transaction that includes both zSQL calls
 has not yet been commited.
 
 I handled this with a call to an external script as below, eg
 
 . zSql1()
 . pyCommit()
 zSql2()
 Publish new page
 
 Here's pyCommit()
 
 # ...
 # Extenstion/pyCommit.py
 # ...
 from ZODB import FileStorage,DB
 
 def commit( self ):
t = get_transaction() # ZODB builtin
if t:
   t.commit()
 # ...
 
 Thats it. And it solved my problem. Is there a reason why this is a bad
 idea, all things being equal?  A better way to do it, when needed?
 

you're playing with fire  ;)

let zope handle the transaction

use dtml-var sql_delimeter to separate two or more sql calls

this way, if one of the call fails, the transaction will be aborted

gurus, correct me if i'm wrong, please

hth

 Thanks,
 David
 
 ___
 Zope maillist  -  Zope@zope.org
 http://mail.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists -
  http://mail.zope.org/mailman/listinfo/zope-announce
  http://mail.zope.org/mailman/listinfo/zope-dev )
 


-- 
http://myzope.kedai.com.my - my-zope org
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Forcing Zope transaction commit

2005-07-19 Thread David H




Bakhtiar A Hamid wrote:

  On 7/19/05, David H [EMAIL PROTECTED] wrote:
  
  
Hi list,

At times (it seems)  necessary to force a Zope transaction commit.  This
might occur between two zSQL calls where the second depends on the
first's *SQL* transaction's availability but the first has not yet been
commited because the *Zope* transaction that includes both zSQL calls
has not yet been commited.

I handled this with a call to an external script as below, eg

. zSql1()
. pyCommit()
zSql2()
Publish new page

Here's pyCommit()

# ...
# Extenstion/pyCommit.py
# ...
from ZODB import FileStorage,DB

def commit( self ):
   t = get_transaction() # ZODB builtin
   if t:
  t.commit()
# ...

Thats it. And it solved my problem. Is there a reason why this is a bad
idea, all things being equal?  A better way to do it, when needed?


  
  
you're playing with fire  ;)

let zope handle the transaction

use dtml-var sql_delimeter to separate two or more sql calls

this way, if one of the call fails, the transaction will be aborted

gurus, correct me if i'm wrong, please

hth

  
  

Bakhtiar,

Thanks very much for responding.

Your idea is what I thought of at first - but my Interbase Adapter
doesn't like COMMIT statements (!) and I didn't test it out. But it
seems that would not solve the problem because both ZSQL methods are
embedded in the *same* zope transaction stream, e.g.

. Submit a page
. call ZSQL1 (part of Zope Tran 100)
. call ZSQL2 (part of Zope Tran 100) --- this depends on zSqL1
being executed but the transaction has not been executed yet, its
pending.
. Display a page
. *now* Zope commits (executes all calls - which is too late in this
case).

When ZSQL2 is called ZSQL1's results are not yet executed into my RDMS
and therefore ZSQL2 cannot see whatever ZSQL1 did. (COMMITs not
with-standing).

Its understandable that Zope might wait between page presentations to
transact all changes until
all succeed ( an exception aborts the transaction). Its just in some
cases they can't all succeed until some
are transacted.

David





(even with your recommended COMMIT) is not available at the time ZSQL2
is called.

>From what i've seen it appears that Zope commits transactions 

David





___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Forcing Zope transaction commit

2005-07-19 Thread m . bizzarri
It would be better if you explain what you're trying to obtain. Inside a
single *Zope* transaction, all the queries are inside the same *RDBMS*
transaction.

Therefore, the second sql method should see the effects of the first
one. If that is not the case, review what is actually happening (i.e.
the first query may be failing even though you did not detect it).

Regards
Marco




On Mon, Jul 18, 2005 at 09:14:26PM -0700, David H wrote:
 Hi list,
 
 At times (it seems)  necessary to force a Zope transaction commit.  This 
 might occur between two zSQL calls where the second depends on the 
 first's *SQL* transaction's availability but the first has not yet been 
 commited because the *Zope* transaction that includes both zSQL calls 
 has not yet been commited.
 
 I handled this with a call to an external script as below, eg
 
 . zSql1()
 . pyCommit() 
 zSql2()
 Publish new page
 
 Here's pyCommit()
 
 # ...
 # Extenstion/pyCommit.py
 # ...
 from ZODB import FileStorage,DB
 
 def commit( self ):
   t = get_transaction() # ZODB builtin
   if t:
  t.commit()
 # ...
 
 Thats it. And it solved my problem. Is there a reason why this is a bad 
 idea, all things being equal?  A better way to do it, when needed?
 
 Thanks,
 David
 
 ___
 Zope maillist  -  Zope@zope.org
 http://mail.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )

-- 
Marco Bizzarri - Amministratore Delegato - Icube S.r.l.
Sede:   Via Ridolfi 15 - 56124 Pisa (PI), Italia 
E-mail: [EMAIL PROTECTED]   WWW: www.icube.it   
Tel:(+39) 050 97 02 07  Fax: (+39) 050 31 36 588


signature.asc
Description: Digital signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Forcing Zope transaction commit

2005-07-19 Thread Tino Wildenhain
Am Dienstag, den 19.07.2005, 00:35 -0700 schrieb David H:
...
 Your idea is what I thought of at first - but my Interbase Adapter
 doesn't like COMMIT statements (!)  and I didn't test it out.  But it
 seems that would not  solve the problem because both ZSQL methods are
 embedded in the *same* zope transaction stream, e.g.
 
 .  Submit a page
 .  call ZSQL1 (part of Zope Tran 100)
 . call ZSQL2  (part of Zope Tran 100)  --- this depends on zSqL1
 being executed but the transaction has not been executed yet, its
 pending.
 .  Display a page
 .  *now* Zope commits (executes all calls - which is too late in this
 case).
 
 When ZSQL2 is called ZSQL1's results are not yet executed into my RDMS
 and therefore ZSQL2 cannot see whatever ZSQL1 did. (COMMITs not
 with-standing).


Stop. Should Interbase here behave different? Its actually required
that a database makes changes visible to all queries in the _same
transaction_. It depends on Transaction Isolation Level 
if you see further changes, e.g. if your Database supports read
committed - this means you would see data changed by _other
transactions_ that started _after your transaction_.

 Its understandable that Zope might wait between page presentations to
 transact all changes until all succeed ( an exception aborts the
 transaction).  Its just in some cases they can't all succeed until
 some are transacted.

Thats weird. I'd like to see the model you are referring to here.
Are you perhaps playing with after-commit triggers? 

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Forcing Zope transaction commit

2005-07-18 Thread David H

Hi list,

At times (it seems)  necessary to force a Zope transaction commit.  This 
might occur between two zSQL calls where the second depends on the 
first's *SQL* transaction's availability but the first has not yet been 
commited because the *Zope* transaction that includes both zSQL calls 
has not yet been commited.


I handled this with a call to an external script as below, eg

. zSql1()
. pyCommit() 
zSql2()

Publish new page

Here's pyCommit()

# ...
# Extenstion/pyCommit.py
# ...
from ZODB import FileStorage,DB

def commit( self ):
  t = get_transaction() # ZODB builtin
  if t:
 t.commit()
# ...

Thats it. And it solved my problem. Is there a reason why this is a bad 
idea, all things being equal?  A better way to do it, when needed?


Thanks,
David

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )