Skip to content

Commit

Permalink
Merge 7fd7cd7 into 14755dd
Browse files Browse the repository at this point in the history
  • Loading branch information
pbauer committed Sep 3, 2017
2 parents 14755dd + 7fd7cd7 commit 22994ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
3 changes: 1 addition & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Changes
4.4.1 (unreleased)
------------------

- Nothing changed yet.

- Remove obsolete call of searchInterface from interfaceToName

4.4.0 (2017-07-25)
------------------
Expand Down
22 changes: 5 additions & 17 deletions src/zope/component/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from zope.component._api import queryUtility
from zope.component._compat import CLASS_TYPES


def provideInterface(id, interface, iface_type=None, info=''):
""" Mark 'interface' as a named utilty providing 'iface_type'.
"""
Expand Down Expand Up @@ -79,7 +80,7 @@ def searchInterfaceUtilities(context, search_string=None, base=None):
if search_string:
search_string = search_string.lower()
iface_utilities = [iface_util for iface_util in iface_utilities
if (getInterfaceAllDocs(iface_util[1]).\
if (getInterfaceAllDocs(iface_util[1]).
find(search_string) >= 0)]
if base:
res = [iface_util for iface_util in iface_utilities
Expand All @@ -90,7 +91,7 @@ def searchInterfaceUtilities(context, search_string=None, base=None):


def getInterfaceAllDocs(interface):
iface_id = '%s.%s' %(interface.__module__, interface.__name__)
iface_id = '%s.%s' % (interface.__module__, interface.__name__)
docs = [str(iface_id).lower(),
str(interface.__doc__).lower()]

Expand All @@ -108,21 +109,8 @@ def nameToInterface(context, id):
iface = getInterface(context, id)
return iface


def interfaceToName(context, interface):
if interface is None:
return 'None'
# XXX this search is pointless: we are always going to return the
# same value whether or not we find anything.
items = searchInterface(context, base=interface)
ids = [('%s.%s' %(iface.__module__, iface.__name__))
for iface in items
if iface == interface]

if not ids:
# Do not fail badly, instead resort to the standard
# way of getting the interface name, cause not all interfaces
# may be registered as utilities.
return interface.__module__ + '.' + interface.__name__

assert len(ids) == 1, "Ambiguous interface names: %s" % ids
return ids[0]
return '%s.%s' % (interface.__module__, interface.__name__)

0 comments on commit 22994ef

Please sign in to comment.