[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/File/Views/VFS - VFSFileView.py:1.1.4.1 __init__.py:1.1.4.1 vfs.zcml:1.1.4.1

Shane Hathaway shane@cvs.zope.org
Fri, 12 Apr 2002 17:30:50 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/File/Views/VFS
In directory cvs.zope.org:/tmp/cvs-serv20835/lib/python/Zope/App/OFS/Content/File/Views/VFS

Added Files:
      Tag: Zope-3x-branch
	VFSFileView.py __init__.py vfs.zcml 
Log Message:
Merged Zope3-Server-Branch.


=== 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.4.1 2002/04/12 21:30:49 shane 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.4.1 2002/04/12 21:30:49 shane 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>