Skip to content

Commit

Permalink
[#3126] don't check if methodcaller is available
Browse files Browse the repository at this point in the history
- `operator.methodcaller` was implemented in python2.7. Now that ckan
  only supports 2.7 it is no longer required to check if the import is
  possible or not. We can besure that it is there.
  • Loading branch information
Knut Hühne committed Jun 17, 2016
1 parent 82fe4fd commit 1efb47a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
12 changes: 2 additions & 10 deletions ckan/model/extension.py
Expand Up @@ -4,23 +4,17 @@
Provides bridges between the model and plugin PluginImplementationss
"""
import logging
from operator import methodcaller

from sqlalchemy.orm.interfaces import MapperExtension
from sqlalchemy.orm.session import SessionExtension

import ckan.plugins as plugins

try:
from operator import methodcaller
except ImportError:
def methodcaller(name, *args, **kwargs):
"Replaces stdlib operator.methodcaller in python <2.6"
def caller(obj):
return getattr(obj, name)(*args, **kwargs)
return caller

log = logging.getLogger(__name__)


class ObserverNotifier(object):
"""
Mixin for hooking into SQLAlchemy
Expand Down Expand Up @@ -93,7 +87,6 @@ def notify_observers(self, func):
for observer in plugins.PluginImplementations(plugins.ISession):
func(observer)


def after_begin(self, session, transaction, connection):
return self.notify_observers(
methodcaller('after_begin', session, transaction, connection)
Expand Down Expand Up @@ -123,4 +116,3 @@ def after_rollback(self, session):
return self.notify_observers(
methodcaller('after_rollback', session)
)

1 change: 0 additions & 1 deletion ckan/tests/legacy/test_coding_standards.py
Expand Up @@ -488,7 +488,6 @@ class TestPep8(object):
'ckan/model/authz.py',
'ckan/model/dashboard.py',
'ckan/model/domain_object.py',
'ckan/model/extension.py',
'ckan/model/follower.py',
'ckan/model/group.py',
'ckan/model/group_extra.py',
Expand Down

0 comments on commit 1efb47a

Please sign in to comment.