[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/VFS - IVFSDirectoryPublisher.py:1.1.2.1 IVFSFilePublisher.py:1.1.2.1 IVFSObjectPublisher.py:1.1.2.1 IVFSPublisher.py:1.1.2.1 InfoPublisher.py:1.1.2.1 VFSRequest.py:1.1.2.1 VFSResponse.py:1.1.2.1 __init__.py:1.1.2.1 metaConfigure.py:1.1.2.1 vfs-meta.py:1.1.2.1 vfs-meta.zcml:1.1.2.1
Stephan Richter
srichter@cbu.edu
Thu, 4 Apr 2002 06:44:53 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/VFS
In directory cvs.zope.org:/tmp/cvs-serv21650/lib/python/Zope/Publisher/VFS
Added Files:
Tag: Zope3-Server-Branch
IVFSDirectoryPublisher.py IVFSFilePublisher.py
IVFSObjectPublisher.py IVFSPublisher.py InfoPublisher.py
VFSRequest.py VFSResponse.py __init__.py metaConfigure.py
vfs-meta.py vfs-meta.zcml
Log Message:
Worked some more on FTP, especially in regards with the Publisher.
- Finally we can get rid of the medusa base. I think I have extracted all
of the interesting code.
- Started on a PublisherFileSystem. A few methods might work, but most of
the FS methods are not hooked up yet.
- Started writing VFS Publisher hooks.
- Added the FTPServer to the startup registry. It comes up, but do not
expect it to work, since no views have been written for VFS yet.
=== 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.2.1 2002/04/04 11:44:51 srichter Exp $
"""
from IVFSObjectPublisher import IVFSObjectPublisher
class IVFSDirectoryPublisher(IVFSObjectPublisher):
""" """
def listdir():
"""Returns a sequence of names"""
def remove(name):
"""Removes a file"""
def rename(oldname, newname):
"""Renames a file"""
def getfile(name):
"""Returns an existing IVFSObject"""
=== 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.2.1 2002/04/04 11:44:51 srichter Exp $
"""
from IVFSObjectPublisher import IVFSObjectPublisher
class IVFSFilePublisher(IVFSObjectPublisher):
""" """
def read():
"""Returns a string or a stream"""
def write(stream):
"""Writes the stream to this 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.2.1 2002/04/04 11:44:51 srichter Exp $
"""
from IVFSPublisher import IVFSPublisher
class IVFSObjectPublisher(IVFSPublisher):
""" """
def stat():
"""Similar to os.stat()"""
=== 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.2.1 2002/04/04 11:44:51 srichter 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/InfoPublisher.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: InfoPublisher.py,v 1.1.2.1 2002/04/04 11:44:51 srichter Exp $
"""
from IVFSPublisher import IVFSPublisher
class InfoPublisher(object):
""" """
__implements__ = IVFSPublisher
############################################################
# Implementation methods for interface
# Zope.Publisher.VFS.IVFSPublisher.
def publishTraverse(self, request, name):
'See Zope.Publisher.VFS.IVFSPublisher.IVFSPublisher'
return getattr(self, name)
#
############################################################
=== 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.2.1 2002/04/04 11:44:51 srichter Exp $
"""
from Zope.Publisher.BaseRequest import BaseRequest
from IVFSPublisher import IVFSPublisher
from VFSResponse import VFSResponse
class VFSRequest(BaseRequest):
__implements__ = BaseRequest.__implements__
# _viewtype is overridden from the BaseRequest
# to implement IVFSPublisher
_viewtype = IVFSPublisher
def __init__(self, body_instream, outstream, environ):
""" """
super(VFSRequest, self).__init__(body_instream, outstream, environ)
self._environ = environ
self.__setupPath()
def _createResponse(self, outstream):
"""Create a specific XML-RPC response object."""
return VFSResponse(outstream)
######################################
# from: Zope.Publisher.IPublisherRequest.IPublisherRequest
def processInputs(self):
'See Zope.Publisher.IPublisherRequest.IPublisherRequest'
if self._environ.has_key('command'):
self.setPathSuffix((self._environ['command'],))
#
############################################################
def __setupPath(self):
path = self.get('PATH_INFO', '/').strip()
if path.endswith('/'):
path = path[:-1] # XXX Why? Not sure
self._endswithslash = 1
else:
self._endswithslash = 0
if path.startswith('/'):
path = path[1:] # XXX Why? Not sure
clean = []
for item in path.split('/'):
if 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
=== 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.2.1 2002/04/04 11:44:51 srichter 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 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.2.1 2002/04/04 11:44:51 srichter 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.2.1 2002/04/04 11:44:51 srichter Exp $
"""
from Zope.ComponentArchitecture import 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),
)
]
=== Added File Zope3/lib/python/Zope/Publisher/VFS/vfs-meta.py ===
<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
<!-- Zope.Publisher.Browser -->
<directives namespace="http://namespaces.zope.org/browser">
<directive name="view" attributes="factory, name, for"
handler="Zope.Publisher.Browser.metaConfigure.view" />
<directive name="defaultView" attributes="factory, name, for"
handler="Zope.Publisher.Browser.metaConfigure.defaultView" />
<directive name="skin" attributes="name, layers"
handler="Zope.Publisher.Browser.metaConfigure.skin" />
</directives>
</zopeConfigure>
=== Added File Zope3/lib/python/Zope/Publisher/VFS/vfs-meta.zcml ===
<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
<!-- Zope.Publisher.VFS -->
<directives namespace="http://namespaces.zope.org/vfs">
<directive name="view" attributes="factory, name, for"
handler="Zope.Publisher.VFS.metaConfigure.view" />
</directives>
</zopeConfigure>