[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/VFS - ZPTTemplateAdd.py:1.1 ZPTTemplateView.py:1.1 __init__.py:1.1 configure.zcml:1.1

Stephan Richter srichter@cbu.edu
Mon, 23 Dec 2002 03:15:40 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/VFS
In directory cvs.zope.org:/tmp/cvs-serv26132/Zope/App/OFS/Services/VFS

Added Files:
	ZPTTemplateAdd.py ZPTTemplateView.py __init__.py 
	configure.zcml 
Log Message:
Implemented VFS views for the Local Service Manager. You can now traverse
into it up to Packages. 

Since Jim did not tell me what he wanted to do in a Package, I did not 
add much there, so that all Services are shown as directories now. The 
only binding I implemented was for the ZPTTemplate, which works fine so
that you can add ZPTs via VFS now. I could imagine doing the same for 
Module, but other than that Package is rather boring from a VFS point of
view.

Of course we could do some "magic" and display a text (file content) 
representation of the various services, but I do not know how useful this 
would be.


=== Added File Zope3/lib/python/Zope/App/OFS/Services/VFS/ZPTTemplateAdd.py ===
##############################################################################
#
# 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.
#
##############################################################################
"""VFS ZPTTemplate Add View

$Id: ZPTTemplateAdd.py,v 1.1 2002/12/23 08:15:39 srichter Exp $
"""
from Zope.Publisher.VFS.VFSView import VFSView

from Zope.Event import publish
from Zope.App.Event.ObjectEvent import ObjectCreatedEvent

from Zope.App.OFS.Services.ServiceManager.IPackageAdding import IPackageAdding
from Zope.App.OFS.Services.zpt import ZPTTemplate


class ZPTTemplateAdd(VFSView):
    "Provide a user interface for adding a ZPTTemplate content object"

    __used_for__ = IPackageAdding

    def __call__(self, mode, instream, start):
        content = ZPTTemplate()
        try:
            instream.seek(start)
        except:
            pass
        content.source = unicode(instream.read())
        
        publish(self.context, ObjectCreatedEvent(content))
        return self.context.add(content)



=== Added File Zope3/lib/python/Zope/App/OFS/Services/VFS/ZPTTemplateView.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.
#
##############################################################################
"""VFS-View for IZPTTemplate

VFS-view implementation for a ZPT Template. 

$Id: ZPTTemplateView.py,v 1.1 2002/12/23 08:15:39 srichter Exp $
"""
from Zope.Publisher.VFS.VFSFileView import VFSFileView

class ZPTTemplateView(VFSFileView):

    def _setData(self, data):
        self.context.source = data

    def _getData(self):
        return self.context.source


=== Added File Zope3/lib/python/Zope/App/OFS/Services/VFS/__init__.py ===


=== Added File Zope3/lib/python/Zope/App/OFS/Services/VFS/configure.zcml ===
<zopeConfigure
   xmlns="http://namespaces.zope.org/zope"
   xmlns:vfs="http://namespaces.zope.org/vfs">

  <vfs:view name="vfs" 
       for="Zope.App.OFS.Services.interfaces.IZPTTemplate"
       permission="Zope.View" 
       allowed_interface="Zope.Publisher.VFS.IVFSFilePublisher."
       factory=".ZPTTemplateView." />

  <vfs:view
      name=".pt"
      for="Zope.App.OFS.Services.ServiceManager.IPackageAdding."
      factory=".ZPTTemplateAdd."
      permission="Zope.ManageContent" />

  <vfs:view
      name=".zpt"
      for="Zope.App.OFS.Services.ServiceManager.IPackageAdding."
      factory=".ZPTTemplateAdd."
      permission="Zope.ManageContent" />

</zopeConfigure>