[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/VFS - IVFSCredentials.py:1.2 IVFSDirectoryPublisher.py:1.2 IVFSFilePublisher.py:1.2 IVFSObjectPublisher.py:1.2 IVFSPresentation.py:1.2 IVFSPublisher.py:1.2 IVFSView.py:1.2 VFSRequest.py:1.2 VFSResponse.py:1.2 __init__.py:1.2 metaConfigure.py:1.2 vfs-meta.zcml:1.2

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 19:30:05 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/VFS
In directory cvs.zope.org:/tmp/cvs-serv20468/lib/python/Zope/Publisher/VFS

Added Files:
	IVFSCredentials.py IVFSDirectoryPublisher.py 
	IVFSFilePublisher.py IVFSObjectPublisher.py 
	IVFSPresentation.py IVFSPublisher.py IVFSView.py VFSRequest.py 
	VFSResponse.py __init__.py metaConfigure.py vfs-meta.zcml 
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.

=== Zope3/lib/python/Zope/Publisher/VFS/IVFSCredentials.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+from Interface import Interface
+
+class IVFSCredentials(Interface):
+
+    # XXX Eventually this will be a different method
+    def _authUserPW():
+        """Return (login, password) if there are basic credentials;
+        return None if there aren't."""
+
+    def unauthorized(challenge):
+        """Issue a 401 Unauthorized error (asking for login/password).
+        The challenge is the value of the WWW-Authenticate header."""


=== Zope3/lib/python/Zope/Publisher/VFS/IVFSDirectoryPublisher.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+from IVFSObjectPublisher import IVFSObjectPublisher
+
+
+class IVFSDirectoryPublisher(IVFSObjectPublisher):
+    """ """
+
+    def exists(name):
+        """Checks whether the name exists.
+        """
+
+    def listdir(with_stats=0, pattern='*'):
+        """Returns a sequence of names ot (name, stat)
+        """
+
+    def mkdir(name, mode=0777):
+        """Create a container with name in this object.
+        """
+
+    def remove(name):
+        """Remove file with naem from this container.
+        """
+
+    def rmdir(name):
+        """Remove the container name from this container.
+        """
+
+    def rename(old, new):
+        """Rename an object from old name to new name.
+        """
+
+    def writefile(name, mode, instream, start=0):
+        """Write a file to the container. If the object does not exist,
+           inspect the content and the file name to create the right object
+           type.
+        """
+
+    def check_writable(name):
+        """Check whether we can write to a subobject.
+        """


=== Zope3/lib/python/Zope/Publisher/VFS/IVFSFilePublisher.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+from IVFSObjectPublisher import IVFSObjectPublisher
+
+class IVFSFilePublisher(IVFSObjectPublisher):
+    """This interface describes the necessary methods a VFS view has to
+       implement in order to be used by teh VFS.
+    """
+
+    def read(mode, outstream, start=0, end=-1):
+        """Read the content of this object.
+        """
+        
+    def write(mode, instream, start=0):
+        """Write data specified in instream to object.
+        """


=== Zope3/lib/python/Zope/Publisher/VFS/IVFSObjectPublisher.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+from IVFSPublisher import IVFSPublisher
+
+class IVFSObjectPublisher(IVFSPublisher):
+    """ """
+
+    def isdir():
+        """Returns true, if the object is a container, namely implements
+           IContainer. For all other cases it returns false.
+        """
+
+    def isfile():
+        """Returns always the oposite of isdir() for the same reasons.
+        """
+
+    def stat():
+        """This method should return the typical file stat information: 
+           (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)
+        """


=== Zope3/lib/python/Zope/Publisher/VFS/IVFSPresentation.py 1.1 => 1.2 ===
+#
+# Copyright (c) 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$
+"""
+
+from Zope.ComponentArchitecture.IPresentation import IPresentation
+
+class IVFSPresentation(IPresentation):
+    """VFS presentations
+    """
+


=== Zope3/lib/python/Zope/Publisher/VFS/IVFSPublisher.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+from Zope.Publisher.IPublishTraverse import IPublishTraverse
+
+class IVFSPublisher(IPublishTraverse):
+    """VFS Publisher"""


=== Zope3/lib/python/Zope/Publisher/VFS/IVFSView.py 1.1 => 1.2 ===
+#
+# Copyright (c) 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$
+"""
+
+from Zope.ComponentArchitecture.IView import IView
+from IVFSPresentation import IVFSPresentation
+
+class IVFSView(IVFSPresentation, IView):
+    "Browser View"
+


=== Zope3/lib/python/Zope/Publisher/VFS/VFSRequest.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+
+from Zope.Publisher.BaseRequest import BaseRequest
+from IVFSView import IVFSView
+from IVFSCredentials import IVFSCredentials
+
+from VFSResponse import VFSResponse
+
+class VFSRequest(BaseRequest):
+
+    __implements__ = BaseRequest.__implements__, IVFSCredentials
+
+    # _presentation_type is overridden from the BaseRequest 
+    # to implement IVFSView
+    _presentation_type = IVFSView
+
+
+    def __init__(self, body_instream, outstream, environ, response=None):
+        """ """
+        super(VFSRequest, self).__init__(
+            body_instream, outstream, environ, response)
+
+        self._environ = environ
+        self.method = ''
+        self.__setupPath()
+
+
+    def _createResponse(self, outstream):
+        """Create a specific XML-RPC response object."""
+        return VFSResponse(outstream)
+
+
+    ############################################################
+    # Implementation methods for interface
+    # Zope.Publisher.VFS.IVFSCredentials.
+
+    def _authUserPW(self):
+        'See Zope.Publisher.VFS.IVFSCredentials.IVFSCredentials'
+        # XXX This is wrong.  Instead of _authUserPW() there should
+        # be a method of all requests called getCredentials() which
+        # returns an ICredentials instance.
+        credentials = self._environ['credentials']
+        return credentials.getUserName(), credentials.getPassword()
+
+    def unauthorized(self, challenge):
+        'See Zope.Publisher.VFS.IVFSCredentials.IVFSCredentials'
+        pass
+    #
+    ############################################################
+    
+    ######################################
+    # from: Zope.Publisher.IPublisherRequest.IPublisherRequest
+
+    def processInputs(self):
+        'See Zope.Publisher.IPublisherRequest.IPublisherRequest'
+
+        if 'command' in self._environ:
+            self.method = self._environ['command']
+
+    #
+    ############################################################
+
+
+    def __setupPath(self):
+        path = self.get('path', '/').strip()
+
+        if path.endswith('/'):
+            path = path[:-1] # XXX Why? Not sure
+            self._endswithslash = 1
+        else:
+            self._endswithslash = 0
+        
+        clean = []
+        for item in path.split('/'):
+            if not item or item == '.':
+                continue
+            elif item == '..':
+                try: del clean[-1]
+                except IndexError:
+                    raise NotFound('..')
+            else: clean.append(item)
+
+        clean.reverse()
+        self.setTraversalStack(clean)
+
+        self._path_suffix = None
+
+
+    def __repr__(self):
+        # Returns a *short* string.
+        return '<%s instance at 0x%x, path=%s>' % (
+            str(self.__class__), id(self), '/'.join(self._traversal_stack))


=== Zope3/lib/python/Zope/Publisher/VFS/VFSResponse.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+
+from Zope.Publisher.BaseResponse import BaseResponse
+
+
+class VFSResponse(BaseResponse):
+    """VFS response
+    """
+    __slots__ = (
+        '_exc',
+        )
+
+    def setBody(self, body):
+        """Sets the body of the response
+
+           It is very important to note that in this case the body may
+           not be just a astring, but any Python object.
+        """
+        
+        self._body = body
+
+
+    def outputBody(self):
+        'See Zope.Publisher.IPublisherResponse.IPublisherResponse'
+        pass
+
+
+    def getResult(self):
+        """ """
+        if getattr(self, '_exc', None) is not None:
+            raise self._exc[0], self._exc[1]
+        return self._getBody()
+
+
+    def handleException(self, exc_info):
+        """
+        """
+        self._exc = exc_info[:2]
+        #import traceback
+        #traceback.print_exc()


=== Zope3/lib/python/Zope/Publisher/VFS/__init__.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+


=== Zope3/lib/python/Zope/Publisher/VFS/metaConfigure.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+from Zope.App.ComponentArchitecture.metaConfigure import view as _view
+    
+def view(_context, **__kw):
+    return _view(_context, type='Zope.Publisher.VFS.IVFSView.', **__kw)
+
+


=== Zope3/lib/python/Zope/Publisher/VFS/vfs-meta.zcml 1.1 => 1.2 ===
+  
+  <directives namespace="http://namespaces.zope.org/vfs">
+    <directive name="view" attributes="factory name for"
+       handler=".metaConfigure.view" />
+  </directives>
+
+</zopeConfigure>