Skip to content

Commit

Permalink
revert to callable() check
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli committed Oct 17, 2017
1 parent 62c15f4 commit 8f4b1e3
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 22 deletions.
3 changes: 1 addition & 2 deletions src/App/Common.py
Expand Up @@ -20,7 +20,6 @@

# BBB
from os.path import realpath # NOQA
import collections
attrget = getattr

# These are needed because the various date formats below must
Expand Down Expand Up @@ -72,7 +71,7 @@ def rfc1123_date(ts=None):
def absattr(attr, callable=callable):
# Return the absolute value of an attribute,
# calling the attr if it is callable.
if isinstance(attr, collections.Callable):
if callable(attr):
return attr()
return attr

Expand Down
3 changes: 1 addition & 2 deletions src/OFS/CopySupport.py
Expand Up @@ -13,7 +13,6 @@
"""Copy interface
"""

import collections
from json import dumps
from json import loads
import logging
Expand Down Expand Up @@ -625,7 +624,7 @@ def sanity_check(c, ob):


def absattr(attr):
if isinstance(attr, collections.Callable):
if callable(attr):
return attr()
return attr

Expand Down
3 changes: 1 addition & 2 deletions src/OFS/FindSupport.py
Expand Up @@ -27,7 +27,6 @@
from zope.interface import implementer

from OFS.interfaces import IFindSupport
import collections


@implementer(IFindSupport)
Expand Down Expand Up @@ -212,6 +211,6 @@ def role_match(ob, permission, roles, lt=type([]), tt=type(())):


def absattr(attr):
if isinstance(attr, collections.Callable):
if callable(attr):
return attr()
return attr
2 changes: 1 addition & 1 deletion src/OFS/Moniker.py
Expand Up @@ -52,6 +52,6 @@ def loadMoniker(data):


def absattr(attr):
if isinstance(attr, collections.Callable):
if callable(attr):
return attr()
return attr
3 changes: 1 addition & 2 deletions src/OFS/ObjectManager.py
Expand Up @@ -15,7 +15,6 @@

from io import BytesIO
from logging import getLogger
import collections
import copy
import fnmatch
import marshal
Expand Down Expand Up @@ -270,7 +269,7 @@ def filtered_meta_types(self, user=None):
# adequate permission to add that type of object.
sm = getSecurityManager()
meta_types = []
if isinstance(self.all_meta_types, collections.Callable):
if callable(self.all_meta_types):
all = self.all_meta_types()
else:
all = self.all_meta_types
Expand Down
7 changes: 3 additions & 4 deletions src/OFS/SimpleItem.py
Expand Up @@ -61,7 +61,6 @@
from OFS.Lockable import LockableItem
from OFS.role import RoleManager
from OFS.Traversable import Traversable
import collections

if bbb.HAS_ZSERVER:
from webdav.Resource import Resource
Expand Down Expand Up @@ -135,7 +134,7 @@ def title_or_id(self):
"""Return the title if it is not blank and the id otherwise.
"""
title = self.title
if isinstance(title, collections.Callable):
if callable(title):
title = title()
if title:
return title
Expand All @@ -147,7 +146,7 @@ def title_and_id(self):
If the title is not blank, then the id is included in parens.
"""
title = self.title
if isinstance(title, collections.Callable):
if callable(title):
title = title()
id = self.getId()
return title and ("%s (%s)" % (title, id)) or id
Expand Down Expand Up @@ -232,7 +231,7 @@ def raise_standardErrorMessage(

if getattr(aq_base(s), 'isDocTemp', 0):
v = s(client, REQUEST, **kwargs)
elif isinstance(s, collections.Callable):
elif callable(s):
v = s(**kwargs)
else:
v = HTML.__call__(s, client, REQUEST, **kwargs)
Expand Down
4 changes: 1 addition & 3 deletions src/Products/PageTemplates/Expressions.py
Expand Up @@ -17,7 +17,6 @@
"""

import logging
import sys
from six import text_type, binary_type

from zope.component import queryUtility
Expand Down Expand Up @@ -47,7 +46,6 @@
from zope.contentprovider.tales import TALESProviderExpression
from Products.PageTemplates import ZRPythonExpr
from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver
import collections


SecureModuleImporter = ZRPythonExpr._SecureModuleImporter()
Expand Down Expand Up @@ -116,7 +114,7 @@ def render(ob, ns):
# item might be proxied (e.g. modules might have a deprecation
# proxy)
base = removeAllProxies(base)
if isinstance(base, collections.Callable):
if callable(base):
if getattr(base, 'isDocTemp', 0):
ob = ZRPythonExpr.call_with_ns(ob, ns, 2)
else:
Expand Down
3 changes: 1 addition & 2 deletions src/Products/PageTemplates/expression.py
Expand Up @@ -25,7 +25,6 @@
from chameleon.codegen import template

from z3c.pt import expressions
import collections

_marker = object()

Expand Down Expand Up @@ -82,7 +81,7 @@ def __call__(self, base, econtext, call, path_items):
return base

if (getattr(base, '__call__', _marker) is not _marker or
isinstance(base, collections.Callable)):
callable(base)):
base = render(base, econtext)

return base
Expand Down
3 changes: 1 addition & 2 deletions src/Testing/ZopeTestCase/placeless.py
Expand Up @@ -22,7 +22,6 @@

# For convenience
from Zope2.App import zcml # NOQA
import collections


class PlacelessSetup(CAPlacelessSetup,
Expand Down Expand Up @@ -58,7 +57,7 @@ def tearDown(doctesttest=None):


def callZCML(zcml_callback):
if isinstance(zcml_callback, collections.Callable):
if callable(zcml_callback):
zcml_callback()
else:
for func in zcml_callback:
Expand Down
4 changes: 2 additions & 2 deletions src/ZPublisher/HTTPRequest.py
Expand Up @@ -1220,7 +1220,7 @@ def resolve_url(self, url):
# to ensure we are getting the actual object named by
# the given url, and not some kind of default object.
if hasattr(object, 'id'):
if isinstance(object.id, collections.Callable):
if callable(object.id):
name = object.id()
else:
name = object.id
Expand Down Expand Up @@ -1359,7 +1359,7 @@ def get(self, key, default=None, returnTaints=0,
if self._lazies:
v = self._lazies.get(key, _marker)
if v is not _marker:
if isinstance(v, collections.Callable):
if callable(v):
v = v()
self[key] = v # Promote lazy value
del self._lazies[key]
Expand Down

0 comments on commit 8f4b1e3

Please sign in to comment.