Ticket #880 (closed defect: fixed)

Opened 14 years ago

Last modified 14 years ago

Transaction instance has no attribute '_before_commit_index'

Reported by: jmorliaguet Owned by: tziade
Priority: P2 Milestone: CPS 3.3.7
Component: CPSCore Version: unspecified
Severity: normal Keywords: patch Five
Cc:

Description

cannot instanciate new CPS sites on zope-2.7.6

Error Type: AttributeError
Error Value: Transaction instance has no attribute '_before_commit_index'

the _before_commit_index error occurs inside existing sites too, this seems related to the event service and the ZODB patch.

Change History

comment:1 Changed 14 years ago by rspivak

  • Owner changed from fguillaume to anguenot

That's because following code in CPSCore/PatchZODB.py fails

if not getattr(Transaction, '_old__init__', False):
    Transaction._old__init__ = Transaction.__init__
    def __init__(self, synchronizers=None, manager=None):
        self._old__init__(synchronizers, manager)
        self._before_commit_index = 0
    Transaction.__init__ = __init__

The reason is that CPSCompat/PatchZODBTransaction.py adds _old__init__ attribute to transaction and thus _before_commit_index is not initialized. You can easily workaround that by adding missing attribute to transaction inside PatchZODB.py, but in general code from both files should be synchronized.

comment:2 Changed 14 years ago by jmorliaguet

the problem is in 3.3.5 also.

I tried to upgrade the z3lab site to 3.3.5 (zope is 2.7.6 + Zope3X + Five on z3lab.org) and got the same error.

    *  Module Products.CPSCore.EventServiceTool, line 256, in notify
    * Module Products.CPSSubscriptions.SubscriptionsTool, line 785, in notify_event
    * Module Products.CPSSubscriptions.EventManager, line 145, in get_event_manager
    * Module Products.CPSSubscriptions.EventManager, line 57, in __init__

AttributeError: 'Transaction' object has no attribute 'beforeCommitHook'

on my laptop I had to remove all event subscribers and run cpsupdate

comment:3 Changed 14 years ago by janguenot

  • Status changed from new to assigned
  • Owner changed from anguenot to janguenot

comment:4 Changed 14 years ago by janguenot

  • Milestone changed from unspecified to CPS 3.3.6

My ZODB branch has been merged thus this code will movde within CPSCompat now.

Are you using Five on your failing instance ? I Can't reproduce the error on Zope-2.8.x.

comment:5 Changed 14 years ago by jmorliaguet

I could reproduce it both with and without Five.

What I did is that I transfered the Data.fs from z3lab.org to my laptop to upgrade the instance. I couldn't run cpsupdate because of the:

AttributeError: 'Transaction' object has no attribute 'beforeCommitHook'

this occurs on the portal_events tool.

To reproduce the error, you can use the following files:

gironde:/home/zope/z3lab.org/Products-new (this is a CPS3.3.5 + CPSBlog svn + CPSSkins svn + Five) gironde:/home/zope/z3lab.org/var/Data.fs-new

and try 'cpsupdate' or go to the 'blog' section of the site.

you will get the error

comment:6 Changed 14 years ago by janguenot

I moved the patch for ZODB 3.5 ordering before commit hooks within CPSCompat. Can you try it out please ?

comment:7 Changed 14 years ago by janguenot

Note, you'll need to take the latest CPSCore as well because the ZODB Patch is no longer there.

comment:8 Changed 14 years ago by jmorliaguet

It works fine now (both cpsupdate and the blog view)

I'm going to try with Five too.

comment:9 Changed 14 years ago by jmorliaguet

  • Keywords Five added

The problem is related to ZopeX3-3.0.0 + Five

this is what I get on a 'cpsupdate':

    *  Module /home/zope/z3lab.org/Products/CPSNewsLetters/Extensions/install.py, line 407, in install
    * Module /home/zope/z3lab.org/Products/CPSNewsLetters/Extensions/install.py, line 73, in install
    * Module /home/zope/z3lab.org/Products/CPSNewsLetters/Extensions/install.py, line 99, in installSchemas
    * Module Products.CPSSchemas.Schema, line 72, in manage_addCPSSchema
    * Module Products.CPSSchemas.Schema, line 53, in addSchema
    * Module OFS.ObjectManager, line 276, in _setObject
    * Module Products.CPSCore.EventServicePatches, line 103, in manage_afterAdd
    * Module Products.CPSCore.EventServicePatches, line 31, in notify
    * Module Products.CPSCore.EventServiceTool, line 256, in notify
    * Module Products.CPSSubscriptions.SubscriptionsTool, line 785, in notify_event
    * Module Products.CPSSubscriptions.EventManager, line 161, in get_event_manager
    * Module Products.CPSSubscriptions.EventManager, line 61, in __init__

AttributeError: 'Transaction' object has no attribute 'addBeforeCommitHook'

If I comment out the lines:

path /usr/local/ZopeX3-3.0.0/lib/python
path $INSTANCE/Products/azax

and move the Five/ azax/ out of Products/ then it works.

comment:10 Changed 14 years ago by janguenot

Using Five (trunk), X3.0.1 and CPS (trunk) does work well.

With Five, azax installed and the etc/zope.conf with the path as below :

path /opt/Zope-X3.0.1/lib/python path $INSTANCE/Products/azax

comment:11 Changed 14 years ago by janguenot

  • Status changed from assigned to closed
  • Resolution set to fixed

This problem had been fixed.

comment:12 Changed 14 years ago by tziade

  • Status changed from closed to reopened
  • Version changed from TRUNK to unspecified
  • Resolution fixed deleted

This problem occured in a migration I have done, (five 1.0.2, zope 2.7.5, zope x3.0.0)

because import transaction catches zope 3 module. without import error,

we need in this case to detect it's z3 transaction module.

One way would be to analyze what's in transaction module object to decide wheter we arein z2 or z3 but it may change. ideas ?

comment:13 Changed 14 years ago by janguenot

Right. I don't have any Five specific cares. I let Florent or someone else deal with that with you.

I do think your solution sounds reasonable though. You may try to implement it within a branch of CPSCompat of off the trunk, if you want to ?

comment:14 Changed 14 years ago by tziade

i think it's overkill to do a branch for that (1 line of code, no impacts), i'll add a test in the trunk that analyzes the imported module.

it'll be based on module elements that can be found only in z3.

If someone comes up with a better idea we will change this test aftewards.

comment:15 Changed 14 years ago by tziade

  • Status changed from reopened to new
  • Severity changed from major to normal
  • Priority changed from P1 to P2
  • Version changed from unspecified to TRUNK
  • Milestone changed from CPS 3.3.6 to CPS 3.4.0
  • Owner changed from janguenot to tziade

to be fixed for migration to 3.3.6 on Zope 2.7.x

comment:16 Changed 14 years ago by janguenot

  • Priority changed from P2 to P1
  • Version changed from TRUNK to unspecified
  • Severity changed from normal to major
  • Milestone changed from CPS 3.4.0 to CPS 3.3.6

ok let's go then so that we don't hear about this Five / Zope-2.7.x pb ;)

comment:17 Changed 14 years ago by tziade

  • Priority changed from P1 to P2
  • Severity changed from major to normal
  • Milestone changed from CPS 3.3.6 to CPS 3.4.0

changed milestone, (to be fixed in 3.4 bug day)

comment:18 Changed 14 years ago by fguillaume

Tarek you said a migration, but what are the versions installed after the migration ? And what CPS version ?

Current CPS is not supposed to work with Five and a Zope 2.7.*. You need 2.8. And the reason is that otherwise it's too much of a mess (you have too many Transaction modules, and you don't know which is Zope's native one).

comment:19 Changed 14 years ago by tziade

  • Status changed from new to closed
  • Resolution set to fixed

ok then, this won't apply to 3.3.6

Note: See TracTickets for help on using tickets.