Fix a PY3-bug when using `transcational` as a class decorator.

Previously this was using ``inspect.ismethod``, which doesn't have the same meaning in Python3.
This commit is contained in:
Ryan Petrello
2013-04-30 17:08:50 -04:00
parent 9dd59a1395
commit b61e022115

View File

@@ -1,4 +1,6 @@
from inspect import getargspec, getmembers, isclass, ismethod
from inspect import getargspec, getmembers, isclass, ismethod, isfunction
import six
from .util import _cfg
@@ -75,7 +77,10 @@ def transactional(ignore_redirects=True):
def deco(f):
if isclass(f):
for meth in [m[1] for m in getmembers(f) if ismethod(m[1])]:
for meth in [
m[1] for m in getmembers(f)
if (isfunction if six.PY3 else ismethod)(m[1])
]:
if getattr(meth, 'exposed', False):
_cfg(meth)['transactional'] = True
_cfg(meth)['transactional_ignore_redirects'] = _cfg(