[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/SOAP - SOAPPublication.py:1.1.2.1 SOAPPublicationTraverse.py:1.1.2.1 SOAPTraversers.py:1.1.2.1 __init__.py:1.1.2.1 soap.zcml:1.1.2.1

Stephan Richter srichter@cbu.edu
Wed, 13 Mar 2002 05:57:32 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/SOAP
In directory cvs.zope.org:/tmp/cvs-serv11175/lib/python/Zope/App/ZopePublication/SOAP

Added Files:
      Tag: srichter-OFS_Formulator-branch
	SOAPPublication.py SOAPPublicationTraverse.py 
	SOAPTraversers.py __init__.py soap.zcml 
Log Message:
- Added some more tests. Won;t do more, since Publisher is being redesigned
  later this week. I will wait until then.

- Added preliminary SOAP support, so we can test Mozilla's SOAP 
  capabilities. Unfortunately, soaplib is very old; I will look into using 
  SOAPpy instead. It seems fairly complete.


=== Added File Zope3/lib/python/Zope/App/ZopePublication/SOAP/SOAPPublication.py ===
##############################################################################
#
# 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.0 (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
# 
##############################################################################
"""

$Id: SOAPPublication.py,v 1.1.2.1 2002/03/13 10:57:31 srichter Exp $
"""
from Zope.ContextWrapper import wrapper
from Zope.App.Security.SecurityManagement import getSecurityManager
from Zope.ComponentArchitecture import getRequestView

from SOAPPublicationTraverse import SOAPPublicationTraverse
from Zope.App.ZopePublication.ZopePublication import ZopePublication 

from Zope.Publisher.SOAP.ISOAPPublisher import ISOAPPublisher


class SOAPPublication(SOAPPublicationTraverse, ZopePublication):
    """SOAP publication handling."""
        

    def _parameterSetskin(self, pname, pval, request):
        request.setViewSkin(pval)
        

    def getDefaultTraversal(self, request, ob):

        r = ()

        if ISOAPPublisher.isImplementedBy(ob):
            r = ob.soap_default(request)
        else:
            adapter = getRequestView(ob, '_traverse', request , None)
            if adapter is not None:
                r = adapter.soap_default(request)
            else:
                return (ob, None)

        if r[0] is ob: return r
        
        wrapped = wrapper.Wrapper(r[0], ob, name=None)
        getSecurityManager().validate(None, wrapped)
        return (wrapped, r[1])


=== Added File Zope3/lib/python/Zope/App/ZopePublication/SOAP/SOAPPublicationTraverse.py ===
##############################################################################
#
# 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.0 (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
# 
##############################################################################
"""

$Id: SOAPPublicationTraverse.py,v 1.1.2.1 2002/03/13 10:57:31 srichter Exp $
"""

from Zope.Publisher.SOAP.ISOAPPublisher import ISOAPPublisher
from Zope.ComponentArchitecture import getRequestView
from Zope.Publisher.Exceptions import NotFound

from Zope.App.ZopePublication.HTTP.HTTPPublicationTraverse import \
     HTTPPublicationTraverse, HTTPPublicationTraverser


class SOAPPublicationTraverse(HTTPPublicationTraverse):
    """ """

    # XXX WE REALLY SHOULD USE INTERFACES HERE

    def getViewFromObject(self, object, name, request):
                          
        if ISOAPPublisher.isImplementedBy(object):
            view = object.soap_traverse(request, name)
        else:
            print request.getViewType()
            adapter = getRequestView(object, '_traverse', request,
                                     self ) # marker 

            if adapter is not self:
                view =  adapter.soap_traverse(request, name)
            else:
                raise NotFound(object, name, request)

        return view



class SOAPPublicationTraverser(SOAPPublicationTraverse,
                                 HTTPPublicationTraverser):
    """ """
    pass


=== Added File Zope3/lib/python/Zope/App/ZopePublication/SOAP/SOAPTraversers.py ===
##############################################################################
#
# 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.0 (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
# 
##############################################################################
"""

$Id: SOAPTraversers.py,v 1.1.2.1 2002/03/13 10:57:31 srichter Exp $
"""

from Zope.Publisher.Exceptions import Unauthorized, NotFound, DebugError
from Zope.Publisher.SOAP.ISOAPPublisher import ISOAPPublisher
from Zope.ComponentArchitecture \
     import getRequestView, getRequestDefaultViewName


class DefaultTraverser:
    """
    """
    __implements__ = ISOAPPublisher

    def __init__(self, target):
        self.target = target


    def soap_default(self, request):
        #XXX: (hack), we really need this to be component
        # specific. 
        ob = self.target

        # if ob is not a component return 
        if not hasattr(ob, '__implements__'):
            return ob,()
        
        view_name = getRequestDefaultViewName(ob, request)

        view_uri = "%s;view" % view_name
        return ob, (view_uri,)


    def soap_traverse(self, request, name):
        """ """
        # TODO:  Look for default view
        ob = self.target
        if name.startswith('_'):
            raise Unauthorized("Name %s begins with an underscore" % `name`)
        if name.endswith(';view'):
            return getRequestView( ob, name[:-5], request)
        if hasattr(ob, name):
            subob = getattr(ob, name)
        else:
            try:
                subob = ob[name]
            except (KeyError, IndexError,
                    TypeError, AttributeError):
                raise NotFound(ob, name, request)

        return subob



=== Added File Zope3/lib/python/Zope/App/ZopePublication/SOAP/__init__.py ===
##############################################################################
#
# 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.0 (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
# 
##############################################################################
"""
Zope publication package.

$Id: __init__.py,v 1.1.2.1 2002/03/13 10:57:31 srichter Exp $
"""


=== Added File Zope3/lib/python/Zope/App/ZopePublication/SOAP/soap.zcml ===
<zopeConfigure
   xmlns='http://namespaces.zope.org/zope'
   xmlns:soap='http://namespaces.zope.org/soap'
>

  <soap:view name="_traverse" 
    factory="Zope.App.ZopePublication.SOAP.SOAPTraversers.DefaultTraverser." />


</zopeConfigure>