[Zope3-checkins] SVN: Zope3/trunk/ - Made zope.app.publication use
the component architecture to look up the
Christian Theune
ct at gocept.com
Thu Apr 26 10:52:52 EDT 2007
Log message for revision 74784:
- Made zope.app.publication use the component architecture to look up the
global authentication utility.
Changed:
U Zope3/trunk/doc/CHANGES.txt
U Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py
U Zope3/trunk/src/zope/app/publication/zopepublication.py
U Zope3/trunk/src/zope/app/wsgi/tests.py
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2007-04-26 14:52:38 UTC (rev 74783)
+++ Zope3/trunk/doc/CHANGES.txt 2007-04-26 14:52:51 UTC (rev 74784)
@@ -18,6 +18,9 @@
Bugs fixed
+ - Made zope.app.publication use the component architecture to look up
+ the global authentication utility.
+
- #98307: PROPFIND with a unicode ID fails
- Password managers now accept full Unicode characters range for
Modified: Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py 2007-04-26 14:52:38 UTC (rev 74783)
+++ Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py 2007-04-26 14:52:51 UTC (rev 74784)
@@ -29,6 +29,7 @@
from zope.interface import implements, classImplements, implementedBy
from zope.i18n.interfaces import IUserPreferredCharsets
from zope.component.interfaces import ComponentLookupError
+from zope.location import Location
from zope.publisher.base import TestPublication, TestRequest
from zope.publisher.http import IHTTPRequest, HTTPCharsets
from zope.publisher.interfaces import IRequest, IPublishTraverse
@@ -46,9 +47,11 @@
from zope.app.security.interfaces import IUnauthenticatedPrincipal, IPrincipal
from zope.app.publication.zopepublication import ZopePublication
from zope.app.folder import Folder, rootFolder
-from zope.location import Location
from zope.app.security.interfaces import IAuthenticationUtility
+from zope.app.security.interfaces import IAuthentication
+from zope.app.security.principalregistry import principalRegistry
+
class Principal(object):
implements(IPrincipal)
def __init__(self, id):
@@ -112,6 +115,8 @@
self.storage = DemoStorage('test_storage')
self.db = db = DB(self.storage)
+ ztapi.provideUtility(IAuthentication, principalRegistry)
+
connection = db.open()
root = connection.root()
app = getattr(root, ZopePublication.root_name, None)
Modified: Zope3/trunk/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/zopepublication.py 2007-04-26 14:52:38 UTC (rev 74783)
+++ Zope3/trunk/src/zope/app/publication/zopepublication.py 2007-04-26 14:52:51 UTC (rev 74784)
@@ -24,6 +24,7 @@
from ZODB.POSException import ConflictError
import transaction
+import zope.component
from zope.event import notify
from zope.security.interfaces import Unauthorized
from zope.interface import implements, providedBy
@@ -36,6 +37,7 @@
from zope.traversing.interfaces import IPhysicallyLocatable
from zope.location import LocationProxy
+import zope.app.security.interfaces
from zope.app import zapi
from zope.app.applicationcontrol.applicationcontrol \
import applicationControllerRoot
@@ -44,7 +46,6 @@
from zope.app.publication.interfaces import BeforeTraverseEvent
from zope.app.publication.interfaces import EndRequestEvent
from zope.app.publication.publicationtraverse import PublicationTraverse
-from zope.app.security.principalregistry import principalRegistry as prin_reg
from zope.app.security.interfaces import IUnauthenticatedPrincipal
from zope.app.security.interfaces import IAuthentication
from zope.app.component.interfaces import ISite
@@ -79,9 +80,11 @@
def beforeTraversal(self, request):
# Try to authenticate against the default global registry.
- p = prin_reg.authenticate(request)
+ auth = zope.component.getGlobalSiteManager().getUtility(
+ zope.app.security.interfaces.IAuthentication)
+ p = auth.authenticate(request)
if p is None:
- p = prin_reg.unauthenticatedPrincipal()
+ p = auth.unauthenticatedPrincipal()
if p is None:
raise Unauthorized # If there's no default principal
Modified: Zope3/trunk/src/zope/app/wsgi/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/wsgi/tests.py 2007-04-26 14:52:38 UTC (rev 74783)
+++ Zope3/trunk/src/zope/app/wsgi/tests.py 2007-04-26 14:52:51 UTC (rev 74784)
@@ -22,14 +22,18 @@
from zope.testing import doctest
import zope.publisher.interfaces.browser
-from zope.app.testing import placelesssetup
+from zope.app.testing import placelesssetup, ztapi
from zope.app.publication.requestpublicationregistry import factoryRegistry
from zope.app.publication.requestpublicationfactories import BrowserFactory
from zope.app.wsgi.testing import AppWSGILayer
+from zope.app.security.interfaces import IAuthentication
+from zope.app.security.principalregistry import principalRegistry
+
def setUp(test):
placelesssetup.setUp(test)
factoryRegistry.register('GET', '*', 'browser', 0, BrowserFactory())
+ ztapi.provideUtility(IAuthentication, principalRegistry)
More information about the Zope3-Checkins
mailing list