Skip to content

Commit

Permalink
Backed out rev27060, I will try to merge the revisions one by one. Also
Browse files Browse the repository at this point in the history
merged in 27037, since it fixed the last failure.
  • Loading branch information
strichter committed Aug 12, 2004
1 parent cef7ec5 commit 5752673
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 63 deletions.
15 changes: 15 additions & 0 deletions configure.zcml
Expand Up @@ -32,6 +32,21 @@
factory="zope.app.utility.vocabulary.UtilityVocabulary"
interface="zope.interface.interfaces.IInterface" />

<hook
module="zope.component"
name="getServices"
implementation="zope.app.component.hooks.getServices_hook" />

<hook
module="zope.component"
name="adapter_hook"
implementation="zope.app.component.hooks.adapter_hook" />

<hook
module="zope.component"
name="queryView"
implementation="zope.app.component.hooks.queryView" />

<interface interface="zope.interface.Interface" />

<adapter
Expand Down
11 changes: 0 additions & 11 deletions hooks.py
Expand Up @@ -15,7 +15,6 @@
$Id$
"""
import zope.component
from zope.component import getService
from zope.component.interfaces import IServiceService
from zope.app.site.interfaces import ISite
Expand Down Expand Up @@ -87,18 +86,11 @@ def getServices_hook(context=None):
except ComponentLookupError:
return serviceManager

# Hook up a new implementation of looking up services.
zope.component.getServices.sethook(getServices_hook)

def adapter_hook(interface, object, name='', default=None):
try:
return siteinfo.adapter_hook(interface, object, name, default)
except ComponentLookupError:
return default

# Hook up a new implementation of looking up adapters.
zope.component.adapter_hook.sethook(adapter_hook)


def queryView(object, name, request, default=None,
providing=Interface, context=None):
Expand All @@ -109,6 +101,3 @@ def queryView(object, name, request, default=None,
locate(view, object, name)

return view

# Hook up a new implementation of looking up views.
zope.component.queryView.sethook(queryView)
117 changes: 65 additions & 52 deletions tests/test_servicedirective.py
Expand Up @@ -60,49 +60,53 @@ def testServiceConfigNoType(self):
UndefinedService,
xmlconfig,
StringIO(template % (
'''
"""
<service
serviceType="Foo"
component="zope.app.component.tests.service.fooService"
/>
'''
serviceType="Foo"
component="
zope.app.component.tests.service.fooService"
/>
"""
)))

def testDuplicateServiceConfig(self):
self.assertRaises(
ConfigurationConflictError,
xmlconfig,
StringIO(template % (
'''
<serviceType
id="Foo"
interface="zope.app.component.tests.service.IFooService"
/>
"""
<serviceType id="Foo"
interface="
zope.app.component.tests.service.IFooService"
/>
<service
serviceType="Foo"
component="zope.app.component.tests.service.fooService"
component="
zope.app.component.tests.service.fooService"
/>
<service
serviceType="Foo"
component="zope.app.component.tests.service.foo2"
component="
zope.app.component.tests.service.foo2"
/>
'''
"""
)))

def testServiceConfig(self):
self.assertRaises(ComponentLookupError, getService, "Foo")

xmlconfig(StringIO(template % (
'''
<serviceType
id="Foo"
interface="zope.app.component.tests.service.IFooService"
/>
"""
<serviceType id="Foo"
interface="
zope.app.component.tests.service.IFooService"
/>
<service
serviceType="Foo"
component="zope.app.component.tests.service.fooService"
/>
'''
serviceType="Foo"
component="
zope.app.component.tests.service.fooService"
/>
"""
)))

service = getService("Foo")
Expand All @@ -114,16 +118,17 @@ def testServiceFactoryConfig(self):
self.assertRaises(ComponentLookupError, getService, "Foo")

xmlconfig(StringIO(template % (
'''
<serviceType
id="Foo"
interface="zope.app.component.tests.service.IFooService"
/>
"""
<serviceType id="Foo"
interface="
zope.app.component.tests.service.IFooService"
/>
<service
serviceType="Foo"
factory="zope.app.component.tests.service.FooService"
/>
'''
serviceType="Foo"
factory="
zope.app.component.tests.service.FooService"
/>
"""
)))

service = getService("Foo")
Expand All @@ -135,17 +140,18 @@ def testPublicProtectedServiceConfig(self):
self.assertRaises(ComponentLookupError, getService, "Foo")

xmlconfig(StringIO(template % (
'''
<serviceType
id="Foo"
interface="zope.app.component.tests.service.IFooService"
/>
"""
<serviceType id="Foo"
interface="
zope.app.component.tests.service.IFooService"
/>
<service
serviceType="Foo"
component="zope.app.component.tests.service.fooService"
permission="zope.Public"
/>
'''
serviceType="Foo"
component="
zope.app.component.tests.service.fooService"
permission="zope.Public"
/>
"""
)))

service = getService("Foo")
Expand All @@ -158,23 +164,30 @@ def testProtectedServiceConfig(self):
self.assertRaises(ComponentLookupError, getService, "Foo")

xmlconfig(StringIO(template % (
'''
<include package="zope.app.security" file="meta.zcml" />
"""
<directives namespace="http://namespaces.zope.org/zope">
<directive name="permission"
attributes="id title description"
handler="
zope.app.security.metaconfigure.definePermission" />
</directives>
<permission id="zope.TestPermission" title="Test permission" />
<serviceType
id="Foo"
interface="zope.app.component.tests.service.IFooService"
/>
<serviceType id="Foo"
interface="
zope.app.component.tests.service.IFooService"
/>
<service
serviceType="Foo"
component="zope.app.component.tests.service.fooService"
permission="zope.TestPermission"
/>
'''
serviceType="Foo"
component="
zope.app.component.tests.service.fooService"
permission="zope.TestPermission"
/>
"""
)))


# Need to "log someone in" to turn on checks
from zope.security.management import newInteraction, endInteraction
endInteraction()
Expand Down

0 comments on commit 5752673

Please sign in to comment.