I have a problem with ZODB's transactions undo. The code I give you
below is written for undoing all the transactions until a given time.
It is the following:

if __name__ == "__main__":
    import getopt
    from datetime import datetime
        opts, args = getopt.getopt(sys.argv[1:], '', ['year=',
'month=', 'day=', 'hour=', 'minute='])
        if len(opts)!=5 or len(args)>0:
            raise Exception, "Usage: undo.py --year YYYY --month MM
--day DD --hour HH --minute MM"
        year = None
        month = None
        day = None
        hour = None
        minute = None
        for o, a in opts:
            if o == '--year':
                year = a
            if o == '--month':
                month = a
            if o == '--day':
                day = a
            if o == '--hour':
                hour = a
            if o == '--minute':
                minute = a
        dt = datetime(int(year), int(month), int(day), int(hour), int(minute))
        if dt > datetime.now():
            raise Exception, "This date belongs to the future."
        Initialization of variable db goes here.
        # Undo the transaction(s):
        i = 0
        while datetime.fromtimestamp(db.undoInfo(i,i+1)[0]['time']) > dt:
            i += 1
        Here goes the commit.
        print "Successfully undone."
    except Exception, msg:
        print msg
        Here goes the abort.

The problem is that sometimes it works fine, but sometimes (even for
the same date and time input as when it worked) there are errors. For
example, for one given date and time input, successive runs of the
script give a successful undo, then an error, then a succes again, and
again and then an error... Really bizarre. Errors are like:

Undo error 0x1fa291: Undo error 0x1fa291: no previous record
Undo error 0x1fa290: Undo error 0x1fa290: no previous record
Undo error 0x1fa3b2: Undo error 0x1fa3b2: _loadBack() failed
Undo error 0x1fa3b3: Undo error 0x1fa3b3: _loadBack() failed
Undo error 0x1fa3b0: Undo error 0x1fa3b0: _loadBack() failed
Undo error 0x1fa3b1: Undo error 0x1fa3b1: _loadBack() failed
Undo error 0x1fa3b6: Undo error 0x1fa3b6: _loadBack() failed

Do someone know what's wrong? Is it the code or maybe a problem with
ZODB itself?

Thanks in advance,

For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to