Skip to content

Commit

Permalink
[ckan#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 0555427
Showing 1 changed file with 2 additions and 10 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)
)

0 comments on commit 0555427

Please sign in to comment.