yuppie  <[EMAIL PROTECTED]> wrote:
> 3.) Zope 2.8 warnings
> 
> 'Zope2' is not available in Zope 2.7 and 'Zope' is deprecated in Zope 
> 2.8. Same with 'transaction' and 'get_transaction'.
> 
> Has anybody a better idea to resolve it than this way:
> 
> http://cvs.zope.org/Products/CMFCore/tests/base/testcase.py.diff?r1=1.11&r2=1.12
> 
> If not, I'll use that pattern for other files and the 1.5 branch as well.

Instead of:

+try:
+    import transaction
+    has_transaction = True
+except ImportError:
+    # BBB: for Zope 2.7
+    has_transaction = False

-        get_transaction().begin()
+        if has_transaction:
+            transaction.begin()
+        else:
+            # BBB: for Zope 2.7
+            get_transaction().begin()

I was thinking of:

try:
    import transaction
except ImportError:
    # BBB: for Zope 2.7
    class BBBTransaction:
        def begin(self): get_transaction().begin()
        def commit(sub=False): get_transaction().commit(sub)
        def abort(sub=False): get_transaction().abort(sub)
    transaction = BBBTransaction()

And just use transaction.begin() everywhere in the code.

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]
_______________________________________________
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to