From 7a3e091c1c9cc9ae6e34279c7c99c9989afd8894 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 24 Sep 2014 15:04:53 -0400 Subject: Unwrap DialectFunctionDispatcher from itself. The DialectFunctionDispatcher.dispatch_for() decorator method necessarily returns the dispatcher itself and not the decorated function, so that the object can continue to be re-used even if the function name is the same as that of the dispatcher. In order to support a single function being wrapped by the dispatcher multiple times with different criteria, dispatch_for() will now check for the last function wrapped and use that. Change-Id: I331670d9b76ae30e7a666648e7e2d4c72641c9ff Closes-Bug: #1373568 --- oslo/db/sqlalchemy/utils.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'oslo') diff --git a/oslo/db/sqlalchemy/utils.py b/oslo/db/sqlalchemy/utils.py index adc9bef..71cd1ea 100644 --- a/oslo/db/sqlalchemy/utils.py +++ b/oslo/db/sqlalchemy/utils.py @@ -899,6 +899,9 @@ class DialectFunctionDispatcher(object): def dispatch_for(self, expr): def decorate(fn): dbname, driver = self._parse_dispatch(expr) + if fn is self: + fn = fn._last + self._last = fn self._register(expr, dbname, driver, fn) return self return decorate -- cgit v1.2.1