Skip to content

Commit

Permalink
Added some bbb and updated the final packages to the new layout. Merged
Browse files Browse the repository at this point in the history
trunk.
  • Loading branch information
strichter committed Jan 17, 2005
2 parents c2120cc + bcd548a commit 9c0af91
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 5 deletions.
16 changes: 13 additions & 3 deletions httpfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from zope.app.publication.http import HTTPPublication
from zope.app.publication.browser import BrowserPublication
from zope.app.publication.xmlrpc import XMLRPCPublication
from zope.app.publication.soap import SOAPPublication
from zope.app.publication.interfaces import ISOAPRequestFactory

_browser_methods = 'GET', 'POST', 'HEAD'

Expand All @@ -41,15 +43,23 @@ def __init__(self, db):
self._http = HTTPPublication(db)
self._brower = BrowserPublication(db)
self._xmlrpc = XMLRPCPublication(db)
self._soappub = SOAPPublication(db)
self._soapreq = zapi.queryUtility(ISOAPRequestFactory)

def __call__(self, input_stream, output_steam, env):
"""See `zope.app.publication.interfaces.IPublicationRequestFactory`"""
method = env.get('REQUEST_METHOD', 'GET').upper()

if method in _browser_methods:
if (method == 'POST' and
env.get('CONTENT_TYPE', '').startswith('text/xml')
):
content_type = env.get('CONTENT_TYPE', '')
is_xml = content_type.startswith('text/xml')

if (method == 'POST' and is_xml and
env.get('HTTP_SOAPACTION', None)
and self._soapreq is not None):
request = self._soapreq(input_stream, output_steam, env)
request.setPublication(self._soappub)
elif (method == 'POST' and is_xml):
request = XMLRPCRequest(input_stream, output_steam, env)
request.setPublication(self._xmlrpc)
else:
Expand Down
61 changes: 61 additions & 0 deletions interfaces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Publication Interfaces
$Id$
"""
__docformat__ = 'restructuredtext'

from zope.interface import implements, Interface

class IPublicationRequestFactory(Interface):
"""Publication request factory"""

def __call__(input_stream, output_steam, env):
"""Create a request object to handle the given inputs
A request is created and configured with a publication object.
"""

class IBeforeTraverseEvent(Interface):
"""An event which gets sent on publication traverse"""


class BeforeTraverseEvent(object):
"""An event which gets sent on publication traverse"""
implements(IBeforeTraverseEvent)
def __init__(self, ob, request):
self.object = ob
self.request = request


class IEndRequestEvent(Interface):
"""An event which gets sent when the publication is ended"""


class EndRequestEvent(object):
"""An event which gets sent when the publication is ended"""
implements(IEndRequestEvent)
def __init__(self, ob, request):
self.object = ob
self.request = request


class ISOAPRequestFactory(Interface):
"""SOAP request factory"""

def __call__(input_stream, output_steam, env):
"""Create a request object to handle SOAP input."""


38 changes: 38 additions & 0 deletions soap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
SOAP Publication Handler. Note that there is no *standard* SOAP
implementation that is currently appropriate for the Zope3 core.
The current architecture allows external packages to register a
utility for zope.app.publication.interfaces.SOAPRequestFactory
in order to implement SOAP support. If no utility is registered
for this interface, SOAP requests are handled as if they were
browser requests.
$Id: $
"""

from zope.app.publication.http import BaseHTTPPublication

# Don't need any special handling for SOAP
SOAPPublication = BaseHTTPPublication

class SOAPPublicationFactory(object):

def __init__(self, db):
self.__pub = SOAPPublication(db)

def __call__(self):
return self.__pub
4 changes: 2 additions & 2 deletions zopepublication.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
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 IAuthenticationUtility
from zope.app.security.interfaces import IAuthentication
from zope.app.component.interfaces import ISite
from zope.app.traversing.interfaces import IPhysicallyLocatable

Expand Down Expand Up @@ -95,7 +95,7 @@ def _maybePlacefullyAuthenticate(self, request, ob):

sm = removeSecurityProxy(ob).getSiteManager()

auth = sm.queryUtility(IAuthenticationUtility)
auth = sm.queryUtility(IAuthentication)
if auth is None:
# No auth utility here
return
Expand Down

0 comments on commit 9c0af91

Please sign in to comment.