[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/VFS - IVFSCredentials.py:1.1.4.1 IVFSDirectoryPublisher.py:1.1.4.1 IVFSFilePublisher.py:1.1.4.1 IVFSObjectPublisher.py:1.1.4.1 IVFSPublisher.py:1.1.4.1 VFSRequest.py:1.1.4.1 VFSResponse.py:1.1.4.1 __init__.py:1.1.4.1 metaConfigure.py:1.1.4.1 vfs-meta.zcml:1.1.4.1
Shane Hathaway
shane@cvs.zope.org
Fri, 12 Apr 2002 17:30:55 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/VFS
In directory cvs.zope.org:/tmp/cvs-serv20835/lib/python/Zope/Publisher/VFS
Added Files:
Tag: Zope-3x-branch
IVFSCredentials.py IVFSDirectoryPublisher.py
IVFSFilePublisher.py IVFSObjectPublisher.py IVFSPublisher.py
VFSRequest.py VFSResponse.py __init__.py metaConfigure.py
vfs-meta.zcml
Log Message:
Merged Zope3-Server-Branch.
=== Added File Zope3/lib/python/Zope/Publisher/VFS/IVFSCredentials.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: IVFSCredentials.py,v 1.1.4.1 2002/04/12 21:30:53 shane Exp $
"""
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."""
=== Added File Zope3/lib/python/Zope/Publisher/VFS/IVFSDirectoryPublisher.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: IVFSDirectoryPublisher.py,v 1.1.4.1 2002/04/12 21:30:53 shane Exp $
"""
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.
"""
=== Added File Zope3/lib/python/Zope/Publisher/VFS/IVFSFilePublisher.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: IVFSFilePublisher.py,v 1.1.4.1 2002/04/12 21:30:53 shane Exp $
"""
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.
"""
=== Added File Zope3/lib/python/Zope/Publisher/VFS/IVFSObjectPublisher.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: IVFSObjectPublisher.py,v 1.1.4.1 2002/04/12 21:30:53 shane Exp $
"""
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)
"""
=== Added File Zope3/lib/python/Zope/Publisher/VFS/IVFSPublisher.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: IVFSPublisher.py,v 1.1.4.1 2002/04/12 21:30:53 shane Exp $
"""
from Interface import Interface
class IVFSPublisher(Interface):
def publishTraverse(request, name):
"""Lookup a name
The request argument is the publisher request object.
"""
=== Added File Zope3/lib/python/Zope/Publisher/VFS/VFSRequest.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: VFSRequest.py,v 1.1.4.1 2002/04/12 21:30:53 shane Exp $
"""
from Zope.Publisher.BaseRequest import BaseRequest
from IVFSPublisher import IVFSPublisher
from IVFSCredentials import IVFSCredentials
from VFSResponse import VFSResponse
class VFSRequest(BaseRequest):
__implements__ = BaseRequest.__implements__, IVFSCredentials
# _viewtype is overridden from the BaseRequest
# to implement IVFSPublisher
_viewtype = IVFSPublisher
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 self._environ.has_key('command'):
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))
=== Added File Zope3/lib/python/Zope/Publisher/VFS/VFSResponse.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: VFSResponse.py,v 1.1.4.1 2002/04/12 21:30:53 shane Exp $
"""
from Zope.Publisher.BaseResponse import BaseResponse
class VFSResponse(BaseResponse):
"""VFS response
"""
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.
"""
# XXX: Handle exceptions
self._body = body
def outputBody(self):
'See Zope.Publisher.IPublisherResponse.IPublisherResponse'
pass
def getResult(self):
""" """
return self._getBody()
def handleException(self, exc_info):
"""
"""
t, value = exc_info[:2]
import traceback
traceback.print_tb(exc_info[2])
print t
print value
self.setBody(value)
=== Added File Zope3/lib/python/Zope/Publisher/VFS/__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.
#
##############################################################################
"""
$Id: __init__.py,v 1.1.4.1 2002/04/12 21:30:53 shane Exp $
"""
=== Added File Zope3/lib/python/Zope/Publisher/VFS/metaConfigure.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: metaConfigure.py,v 1.1.4.1 2002/04/12 21:30:53 shane Exp $
"""
from Zope.ComponentArchitecture import provideView, setDefaultViewName
from Zope.Configuration.Action import Action
from IVFSPublisher import IVFSPublisher
def view(_context, name, factory, for_=None, layer=''):
if for_ is not None:
for_ = _context.resolve(for_)
factory = map(_context.resolve, factory.split(' '))
return [
Action(
discriminator = ('defaultViewName', for_, name, IVFSPublisher),
callable = setDefaultViewName,
args = (for_, IVFSPublisher, name),
),
Action(
discriminator = ('view', for_, name, IVFSPublisher, layer),
callable = provideView,
args = (for_, name, IVFSPublisher, factory, layer),
)
]
=== Added File Zope3/lib/python/Zope/Publisher/VFS/vfs-meta.zcml ===
<zopeConfigure xmlns="http://namespaces.zope.org/zope">
<directives namespace="http://namespaces.zope.org/vfs">
<directive name="view" attributes="factory, name, for"
handler=".metaConfigure.view" />
</directives>
</zopeConfigure>