Skip to content

Commit

Permalink
Merged from trunk r26049:
Browse files Browse the repository at this point in the history
Updated adapter API

as described in:

  http://mail.zope.org/pipermail/zope3-dev/2004-July/011537.html

- query/getAdapter now require a name argument and ignore
  whether the object being adapted provides or conforms to the
  interface.

- New functions 'getAdapterInContext' and 'queryAdapterInContext'
  can be used to do content-dependent simple adapation.  They
  will return the object being adapted if it provides the desired
  interface and will return the result of calling __conform__ if the
  object conforms to the interface.

IMPORTANT

  To do simple adaptation, just call the desired interface:

    adapter = iface(ob) or iface(ob, default)
  • Loading branch information
Jim Fulton committed Jul 6, 2004
1 parent 60d296a commit 9672567
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions hooks.py
Expand Up @@ -16,7 +16,7 @@
$Id$
"""

from zope.component import getService, getAdapter
from zope.component import getService
from zope.component.interfaces import IServiceService
from zope.app.site.interfaces import ISite
from zope.component.service import serviceManager
Expand Down Expand Up @@ -64,17 +64,14 @@ def getServices_hook(context=None):

return services

# Deprecated support for a context that isn't adaptable to
# IServiceService. Return the default service manager.
try:
# This try-except is just backward compatibility really
return trustedRemoveSecurityProxy(getAdapter(context, IServiceService))
return trustedRemoveSecurityProxy(IServiceService(context,
serviceManager))
except ComponentLookupError:
# Deprecated support for a context that isn't adaptable to
# IServiceService. Return the default service manager.
## warnings.warn("getServices' context arg must be None or"
## " adaptable to IServiceService.",
## DeprecationWarning, warningLevel())
return serviceManager


def queryView(object, name, request, default=None,
providing=Interface, context=None):
Expand Down

0 comments on commit 9672567

Please sign in to comment.