Merge lp:~adeuring/launchpad/bug-504755-2 into lp:launchpad
Status: | Merged |
---|---|
Approved by: | Graham Binns |
Approved revision: | no longer in the source branch. |
Merged at revision: | not available |
Proposed branch: | lp:~adeuring/launchpad/bug-504755-2 |
Merge into: | lp:launchpad |
Diff against target: |
335 lines (+115/-20) 8 files modified
lib/canonical/database/ftests/test_zopelesstransactionmanager.txt (+26/-0) lib/canonical/database/sqlbase.py (+10/-0) lib/canonical/launchpad/webapp/adapter.py (+37/-6) lib/canonical/launchpad/webapp/ftests/test_adapter.txt (+19/-0) lib/lp/bugs/doc/checkwatches-cli-switches.txt (+1/-1) lib/lp/bugs/doc/checkwatches.txt (+5/-3) lib/lp/bugs/scripts/checkwatches.py (+13/-7) lib/lp/bugs/scripts/tests/test_checkwatches.py (+4/-3) |
To merge this branch: | bzr merge lp:~adeuring/launchpad/bug-504755-2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Graham Binns (community) | code | Approve | |
Review via email: mp+21950@code.launchpad.net |
Description of the change
This branch adds logging of transaction.
To do so, it registers a synchronizer with the transaction manager. The only problem: The ZopelessTransac
The logging of commit()s is started via canonical.
With these changes, ca. two tests in lib/lp/
tests:
./bin/test -t test_zopelesstr
./bin/test -vvt test_adapter.txt
./bin/test -vvt checkwatches.txt
This looks fine, only a couple of comments:
> === modified file 'lib/canonical/ database/ ftests/ test_zopelesstr ansactionmanage r.txt' database/ ftests/ test_zopelesstr ansactionmanage r.txt 2008-05-19 15:47:23 +0000 database/ ftests/ test_zopelesstr ansactionmanage r.txt 2010-03-23 16:09:52 +0000 self, txn): n(self, txn): (self, txn): ch(synchronizer )
> --- lib/canonical/
> +++ lib/canonical/
> @@ -90,3 +90,29 @@
> >>> print c.fetchone()[0]
> read committed
> >>> ztm.uninstall()
> +
> +we can also register synchronizers with the transaction manager.
> +
> + >>> class testsynchonizer:
> + ... def newtransaction(
> + ... print "new transaction started."
> + ...
> + ... def beforecompletio
> + ... print "transaction will be completed."
> + ...
> + ... def aftercompletion
> + ... print "transaction completed."
> + >>>
> + >>> synchronizer = testsynchonizer()
> + >>> ztm.registersyn
> + >>> ztm.begin()
> + new transaction started.
> + >>> ztm.commit()
> + transaction will be completed.
> + transaction completed.
> +
> +the synchonizer can be ungeristered again.
s/ungeristered/ unregistered
> + ynch(synchroniz er) database/ sqlbase. py' database/ sqlbase. py 2010-01-22 06:25:48 +0000 database/ sqlbase. py 2010-03-23 16:09:52 +0000 synch): manager. registersynch( synch) (synch) : manager. unregistersynch (synch) connection_ cache() : launchpad/ webapp/ adapter. py' launchpad/ webapp/ adapter. py 2010-03-22 13:07:05 +0000 launchpad/ webapp/ adapter. py 2010-03-23 16:09:52 +0000 started( starttime= none, request_ statements= none): self, txn): n(self, txn): (self, txn): started( starttime= none, request_ statements= none, txn=none):
> + >>> ztm.unregisters
> + >>> ztm.begin()
> + >>> ztm.commit()
>
> === modified file 'lib/canonical/
> --- lib/canonical/
> +++ lib/canonical/
> @@ -427,6 +427,16 @@
> """abort the current transaction."""
> transaction.abort()
>
> + @staticmethod
> + def registersynch(
> + """register an isynchronizer."""
> + transaction.
> +
> + @staticmethod
> + def unregistersynch
> + """unregister an isynchronizer."""
> + transaction.
> +
>
> def clear_current_
> """clear sqlobject's object cache. sqlobject compatibility - deprecated.
>
> === modified file 'lib/canonical/
> --- lib/canonical/
> +++ lib/canonical/
> @@ -92,13 +92,36 @@
>
> _local = threading.local()
>
> -def set_request_
> +
> +class commitlogger:
> + def __init__(self, txn):
> + self.txn = txn
> +
> + def newtransaction(
> + pass
> +
> + def beforecompletio
> + pass
> +
> + def aftercompletion
> + now = time()
> + _log_statement(
> + now, now, none, 'transaction completed, status: %s' % txn.status)
> +
> +
> +def set_request_
> """set the start time for the request being served by the current
> thread.
>
> - if the argument is given, it is used as the start time for the
> - request, as returned by time(). if it is not given, the
> + if the argument starttime is given, it is used as the start time for
> + the request, as returned by time(). if it is not given, the...