Re: [ZODB-Dev] when did transaction lose the ability to be usable as a context manager?
2013-02-06 09:57:14 Chris Withers napisał(a): I used to do this: import transaction with transaction: ... print 'hello' ... Traceback (most recent call last): File console, line 1, in module AttributeError: __exit__ When did that stop working and what should I now do instead? http://bugs.python.org/issue9220 -- Arfrever Frehtes Taifersar Arahesis signature.asc Description: This is a digitally signed message part. ___ For more information about ZODB, see http://zodb.org/ ZODB-Dev mailing list - ZODB-Dev@zope.org https://mail.zope.org/mailman/listinfo/zodb-dev
Re: [ZODB-Dev] when did transaction lose the ability to be usable as a context manager?
Chris Withers ch...@simplistix.co.uk wrote: Hi All, I used to do this: import transaction with transaction: ... print 'hello' ... Traceback (most recent call last): File console, line 1, in module AttributeError: __exit__ When did that stop working and what should I now do instead? cheers, Chris You can use pure hackery to work around this: - t.py - def __enter__(*args): print 'enter', args def __exit__(*args): print 'exit', args def fixup(): import sys, types self = sys.modules[__name__] mymod = type(__name__, (types.ModuleType,), globals()) sys.modules[__name__] = mymod(__name__) fixup() -- t1.py --- #!python2.7 import t with t: print transaction and the output is: C:\Tempt1.py enter (module 't' (built-in),) transaction exit (module 't' (built-in), None, None, None) This is hackery though, and watch out for globals as the globals() dict known to the functions in t.py is no longer the same dict visible to modules that import it so changes to one won't be visible in the other and any functions in the module will behave like methods (so you have to give them a 'self' parameter). Much better just to change the code to define an object and import that from the module. ___ For more information about ZODB, see http://zodb.org/ ZODB-Dev mailing list - ZODB-Dev@zope.org https://mail.zope.org/mailman/listinfo/zodb-dev
Re: [ZODB-Dev] [Zope-dev] when did transaction lose the ability to be usable as a context manager?
On 06/02/2013 11:47, Wichert Akkerman wrote: You can also use the transaction manager directly instead of the bound methods transaction lifts out of it: import transaction with transaction.manager: pass yeah, this is what I'll do. Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk ___ For more information about ZODB, see http://zodb.org/ ZODB-Dev mailing list - ZODB-Dev@zope.org https://mail.zope.org/mailman/listinfo/zodb-dev
[ZODB-Dev] zodb conversion questions
Hi there! I hav a relstorage with mysql backend that grew out of bounds and we're looking into different backend solutions now. Possibly also going back to FileStorage and using zeo... Anyway we'll have to convert the databases at some point. As these are live DBs we cannot shut them down for longer than the ususal maintenance interval during the night, so for maybe 2-3h. a full conversion process will never complete in this time so we're looking for a process that can split the conversion into two phases: 1. copy transactions from backup of the source db to the destination db. this can take a long time, we don't care. note the last timestamp/transaction_id converted. 2. shut down the source db 3. copy transactions from the source db to the destination db, starting at the last converted transaction_id. this should be fast, as only a few transactions need to be converted, say 1% . if i would reimplement copyTransactionsFrom() to accept a start transaction_id/timestamp, would this result in dest being an exact copy of source? source = open_my_source_storage() dest = open_my_destination_storage() dest.copyTransactionsFrom(source) last_txn_id = source.lastTransaction() source.close() dest.close() source = open_my_source_storage() # add some transactions source.close() source = open_my_source_storage() dest = open_my_destination_storage() dest.copyTransactionsFrom(source, last_txn_id=last_txn_id) source.close() dest.close() thanks in advance and best regards, Jürgen Herrmann -- XLhost.de ® - Webhosting von supersmall bis eXtra Large XLhost.de GmbH Jürgen Herrmann, Geschäftsführer Boelckestrasse 21, 93051 Regensburg, Germany Geschäftsführer: Jürgen Herrmann Registriert unter: HRB9918 Umsatzsteuer-Identifikationsnummer: DE245931218 Fon: +49 (0)800 XLHOSTDE [0800 95467833] Fax: +49 (0)800 95467830 Web: http://www.XLhost.de ___ For more information about ZODB, see http://zodb.org/ ZODB-Dev mailing list - ZODB-Dev@zope.org https://mail.zope.org/mailman/listinfo/zodb-dev