New ways of getting transactions?
Hi, I'm having some code that bombs out trying to commit a transaction; I believe it's because of new ways of doing things in Zope 2.9.. how do you call the equivalents of get_transaction().commit() and abort() in Zope 2.9? Will those new ways work with Zope 2.7/2.8? Thanks. -- Morten W. Petersen Email: morten@nidelven-it.no Phone: +47 45 44 00 69 Title: Project manager Nidelven IT (http://www.nidelven-it.no) We provide Zope/Plone hosting and consulting
Morten W. Petersen wrote:
Hi,
I'm having some code that bombs out trying to commit a transaction; I believe it's because of new ways of doing things in Zope 2.9.. how do you call the equivalents of get_transaction().commit() and abort() in Zope 2.9? Will those new ways work with Zope 2.7/2.8?
import transaction ... transaction.commit() transaction.abort() Although I think the old way should still work. If it doesn't, please report a bug. Jim -- Jim Fulton mailto:jim@zope.com Python Powered! CTO (540) 361-1714 http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org
A number of ZODB gimmicks were officially deprecated in ZODB 3.4, and removed in ZODB 3.6. Zope 2.9 uses the latter. From the ZODB NEWS file for 3.6: """ Removal of Features Deprecated in ZODB 3.4 ------------------------------------------ (3.6b2) ZODB 3.6 no longer contains features officially deprecated in the ZODB 3.4 release. These include: - ``get_transaction()``. Use ``transaction.get()`` instead. ``transaction.commit()`` is a shortcut spelling of ``transaction.get().commit()``, and ``transaction.abort()`` of ``transaction.get().abort()``. Note that importing ZODB no longer installs ``get_transaction`` as a name in Python's ``__builtin__`` module either. - The ``begin()`` method of ``Transaction`` objects. Use the ``begin()`` method of a transaction manager instead. ``transaction.begin()`` is a shortcut spelling to call the default transaction manager's ``begin()`` method. - The ``dt`` argument to ``Connection.cacheMinimize()``. - The ``Connection.cacheFullSweep()`` method. Use ``cacheMinimize()`` instead. - The ``Connection.getTransaction()`` method. Pass a transaction manager to ``DB.open()`` instead. - The ``Connection.getLocalTransaction()`` method. Pass a transaction manager to ``DB.open()`` instead. - The ``cache_deactivate_after`` and ``version_cache_deactivate_after`` arguments to the ``DB`` constructor. - The ``temporary``, ``force``, and ``waitflag`` arguments to ``DB.open()``. ``DB.open()`` no longer blocks (there's no longer a fixed limit on the number of open connections). - The ``transaction`` and ``txn_mgr``arguments to ``DB.open()``. Use the ``transaction_manager`` argument instead. - The ``getCacheDeactivateAfter``, ``setCacheDeactivateAfter``, ``getVersionCacheDeactivateAfter`` and ``setVersionCacheDeactivateAfter`` methods of ``DB``. """
import transaction transaction.get() transaction.commit() transaction.abort() transaction.savepoint() This works since 2.8, but not in 2.7. Nearly every project has come up with its own backward compatibility module though. See for example CMFCore.utils.transaction or CMFPlone.transaction. Stefan On 11. Dez 2005, at 17:01, Morten W. Petersen wrote:
Hi,
I'm having some code that bombs out trying to commit a transaction; I believe it's because of new ways of doing things in Zope 2.9.. how do you call the equivalents of get_transaction().commit() and abort() in Zope 2.9? Will those new ways work with Zope 2.7/2.8?
Thanks.
-- Morten W. Petersen
-- Anything that happens, happens. --Douglas Adams
Stefan H. Holek wrote:
import transaction transaction.get() transaction.commit() transaction.abort() transaction.savepoint()
This works since 2.8, but not in 2.7. Nearly every project has come up with its own backward compatibility module though. See for example CMFCore.utils.transaction or CMFPlone.transaction.
I'm dispayed to hear this. :( The old use of __builtins__.get_transaction should be deprecated and supported for a period of time. If it isn't, then this is *definately* a bug. Jim -- Jim Fulton mailto:jim@zope.com Python Powered! CTO (540) 361-1714 http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org
This works since 2.8, but not in 2.7. Nearly every project has come up with its own backward compatibility module though. See for example CMFCore.utils.transaction or CMFPlone.transaction.
I'm dispayed to hear this. :( The old use of __builtins__.get_transaction should be deprecated and supported for a period of time. If it isn't, then this is *definately* a bug.
I agree. I've reported it as a bug: http://www.zope.org/Collectors/Zope/1965 -- Morten W. Petersen Email: morten@nidelven-it.no Phone: +47 45 44 00 69 Title: Project manager Nidelven IT (http://www.nidelven-it.no) We provide Zope/Plone hosting and consulting
--On 11. Dezember 2005 12:28:04 -0500 Jim Fulton <jim@zope.com> wrote:
Stefan H. Holek wrote:
import transaction transaction.get() transaction.commit() transaction.abort() transaction.savepoint()
This works since 2.8, but not in 2.7. Nearly every project has come up with its own backward compatibility module though. See for example CMFCore.utils.transaction or CMFPlone.transaction.
I'm dispayed to hear this. :( The old use of __builtins__.get_transaction should be deprecated and supported for a period of time. If it isn't, then this
The deprecation warning in Zope 2.8 says: -c:1: DeprecationWarning: This will be removed in ZODB 3.6: use transaction.get() instead of get_transaction(). transaction.commit() is a shortcut spelling of transaction.get().commit(), and transaction.abort() of transaction.get().abort(). Zope 2.9 comes with ZODB 3.6. So the behaviour is correct in some way but I agree that the deprecation should continue longer. It would be save to remove it in Zope 2.10. -aj
Andreas Jung wrote:
--On 11. Dezember 2005 12:28:04 -0500 Jim Fulton <jim@zope.com> wrote:
Stefan H. Holek wrote:
import transaction transaction.get() transaction.commit() transaction.abort() transaction.savepoint()
This works since 2.8, but not in 2.7. Nearly every project has come up with its own backward compatibility module though. See for example CMFCore.utils.transaction or CMFPlone.transaction.
I'm dispayed to hear this. :( The old use of __builtins__.get_transaction should be deprecated and supported for a period of time. If it isn't, then this
The deprecation warning in Zope 2.8 says:
-c:1: DeprecationWarning: This will be removed in ZODB 3.6: use transaction.get() instead of get_transaction(). transaction.commit() is a shortcut spelling of transaction.get().commit(), and transaction.abort() of transaction.get().abort().
Zope 2.9 comes with ZODB 3.6. So the behaviour is correct in some way but I agree that the deprecation should continue longer. It would be save to remove it in Zope 2.10.
Yup. BTW, This is a good example for why I want to start using time-based deprecation. Jim -- Jim Fulton mailto:jim@zope.com Python Powered! CTO (540) 361-1714 http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org
Tim Peters wrote:
[Jim Fulton] ...
BTW, This is a good example for why I want to start using time-based deprecation.
In a world with time-based releases, is there a difference?
Yes, because release numbers aren't very helpful when software is used by many applications. For example, I could imagine bumping ZODB (or some other packages) release numbers more often than is needed by Zope. For example, zope.interface has separate releases. We might someday decide to make a release to meet Twisted's needs. We wouldn't want such an incedental event to cause a feature to be deprecated more quickly. Jim -- Jim Fulton mailto:jim@zope.com Python Powered! CTO (540) 361-1714 http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org
--On 11. Dezember 2005 17:01:56 +0100 "Morten W. Petersen" <morten@nidelven-it.no> wrote:
Hi,
I'm having some code that bombs out trying to commit a transaction; I believe it's because of new ways of doing things in Zope 2.9.. how do you call the equivalents of get_transaction().commit() and abort() in Zope 2.9? Will those new ways work with Zope 2.7/2.8?
See doc/ZODB.txt. Of course the new API will not work in Zope 2.7/2.8. -aj
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andreas Jung wrote:
--On 11. Dezember 2005 17:01:56 +0100 "Morten W. Petersen" <morten@nidelven-it.no> wrote:
Hi,
I'm having some code that bombs out trying to commit a transaction; I believe it's because of new ways of doing things in Zope 2.9.. how do you call the equivalents of get_transaction().commit() and abort() in Zope 2.9? Will those new ways work with Zope 2.7/2.8?
See doc/ZODB.txt. Of course the new API will not work in Zope 2.7/2.8.
The 'transaction' module is present in Zope 2.8.x / ZODB 3.4.x. Forward compatibility for third-party produccts which need to work on both 2.7.x and 2.8.x+ usually looks like this: try: import transaction except ImportError: class transaction: """ Forward-compatibility for Zope 2.7.x """ def begin(self): get_transaction().begin() def commit(self, sub=False): get_transaction().commit(sub) def abort(self, sub=False): get_transaction().abort(sub) def savepoint(self, optimistic=None): get_transaction().commit(optimistic and 1 or 0) def get(self): return get_transaction() transaction = transaction() I'll agree with Jim and Morten that the deprecated 'get_transaction()' pattern should *not* have been ripped out in Zope 2.9b1 (2.10 is the earliest feasible point, I think). Tres. - -- =================================================================== Tres Seaver +1 202-558-7113 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDnG5W+gerLs4ltQ4RAlDCAJ9n1owUWja8VUoYfOA3qXQEwKK/AwCffWDG YbnO+f8tnKilCYQHVnPeYNk= =7HJy -----END PGP SIGNATURE-----
participants (6)
-
Andreas Jung -
Jim Fulton -
Morten W. Petersen -
Stefan H. Holek -
Tim Peters -
Tres Seaver