[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/File/Views/VFS - VFSFileView.py:1.1.2.1 __init__.py:1.1.2.1 vfs.zcml:1.1.2.1
Stephan Richter
srichter@cbu.edu
Wed, 10 Apr 2002 05:30:54 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/File/Views/VFS
In directory cvs.zope.org:/tmp/cvs-serv23463/lib/python/Zope/App/OFS/Content/File/Views/VFS
Added Files:
Tag: Zope3-Server-Branch
VFSFileView.py __init__.py vfs.zcml
Log Message:
Okay, it finally works! We have a Publisher FTP server again. All the basic
functionalitry is there, from dir listing, file transfer to security.
I punted for now on recognizing file endings, since Jim wants to write a
proposal for that next week. Also, I did not solve the statistical file
information problem, since this takes some more research.
=== Added File Zope3/lib/python/Zope/App/OFS/Content/File/Views/VFS/VFSFileView.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: VFSFileView.py,v 1.1.2.1 2002/04/10 09:30:53 srichter Exp $
"""
import time
from Zope.Publisher.VFS.IVFSFilePublisher import IVFSFilePublisher
class VFSFileView:
__implements__ = IVFSFilePublisher
def __init__(self, context):
""" """
self._object = context
############################################################
# Implementation methods for interface
# Zope.Publisher.VFS.IVFSFilePublisher.
def read(self, mode, outstream, start = 0, end = -1):
"""See Zope.Publisher.VFS.IVFSFilePublisher.IVFSFilePublisher"""
data = self._object.getData()
try:
if start != 0: data = data[start:]
if end != -1: data = data[:end]
except TypeError:
pass
outstream.write(data)
def write(self, mode, instream, start = 0):
"""See Zope.Publisher.VFS.IVFSFilePublisher.IVFSFilePublisher"""
try:
instream.seek(start)
except:
pass
self._object.setData(instream.read())
def check_writable(self, mode):
"""See Zope.Publisher.VFS.IVFSFilePublisher.IVFSFilePublisher"""
return 1
######################################
# from: Zope.Publisher.VFS.IVFSObjectPublisher.IVFSObjectPublisher
def isdir(self):
"""See Zope.Publisher.VFS.IVFSObjectPublisher.IVFSObjectPublisher"""
return 0
def isfile(self):
"""See Zope.Publisher.VFS.IVFSObjectPublisher.IVFSObjectPublisher"""
return 1
def stat(self):
"""See Zope.Publisher.VFS.IVFSObjectPublisher.IVFSObjectPublisher"""
t = time.time()
size = 0
if hasattr(self._object, 'getSize'):
size = self._object.getSize()
uid = 0
gid = 0
return (0, 0, 0, 0, uid, gid, size, t, t, t)
######################################
# from: Zope.Publisher.VFS.IVFSPublisher.IVFSPublisher
def publishTraverse(self, request, name):
"""See Zope.Publisher.VFS.IVFSPublisher.IVFSPublisher"""
return getattr(self, name)
#
############################################################
=== Added File Zope3/lib/python/Zope/App/OFS/Content/File/Views/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/10 09:30:53 srichter Exp $
"""
=== Added File Zope3/lib/python/Zope/App/OFS/Content/File/Views/VFS/vfs.zcml ===
<zopeConfigure
xmlns="http://namespaces.zope.org/zope"
xmlns:security="http://namespaces.zope.org/security"
xmlns:vfs="http://namespaces.zope.org/vfs"
>
<vfs:view name="vfs"
for="Zope.App.OFS.Content.File.IFile."
factory=".VFSFileView." />
<security:protectClass name=".VFSFileView."
permission_id="Zope.ManageContent"
interface="Zope.Publisher.VFS.IVFSFilePublisher." />
</zopeConfigure>