[Zope3-checkins] CVS: Zope3/src/zope/app/vfs/services - __init__.py:1.1.2.1 configure.zcml:1.1.2.1 package.py:1.1.2.1 service.py:1.1.2.1 zpt.py:1.1.2.1

Jim Fulton jim@zope.com
Mon, 23 Dec 2002 14:32:38 -0500


Update of /cvs-repository/Zope3/src/zope/app/vfs/services
In directory cvs.zope.org:/tmp/cvs-serv19908/zope/app/vfs/services

Added Files:
      Tag: NameGeddon-branch
	__init__.py configure.zcml package.py service.py zpt.py 
Log Message:
Initial renaming before debugging

=== Added File Zope3/src/zope/app/vfs/services/__init__.py ===
#
# This file is necessary to make this directory a package.


=== Added File Zope3/src/zope/app/vfs/services/configure.zcml ===
<zopeConfigure
   xmlns="http://namespaces.zope.org/zope"
   xmlns:vfs="http://namespaces.zope.org/vfs">

  <vfs:view name="vfs" 
       for="zope.app.interfaces.services.interfaces.IZPTTemplate"
       permission="Zope.View" 
       allowed_interface="zope.publisher.interfaces.vfs.IVFSFilePublisher"
       factory="zope.app.vfs.services.zpt.ZPTTemplateView" />

  <vfs:view
      name=".pt"
      for="zope.app.interfaces.services.package.IPackageAdding"
      factory="zope.app.vfs.services.zpt.ZPTTemplateAdd"
      permission="Zope.ManageContent" />

  <vfs:view
      name=".zpt"
      for="zope.app.interfaces.services.package.IPackageAdding"
      factory="zope.app.vfs.services.zpt.ZPTTemplateAdd"
      permission="Zope.ManageContent" />

</zopeConfigure>

<zopeConfigure
   xmlns="http://namespaces.zope.org/zope"
   xmlns:vfs="http://namespaces.zope.org/vfs"
>

  <!-- Note that we have to use another Adding interface here, since 
       it conflicts otherwise with the content namespace definitions. --> 

   <vfs:view
       for="zope.app.interfaces.services.package.IPackage"
       name="+"  
       factory="zope.app.vfs.services.package.PackageAdding"
       allowed_attributes="setContentName add"
       permission="Zope.ManageContent" />


   <vfs:view
       for="zope.app.interfaces.container.IContainer"
       name="+"  
       factory="zope.app.vfs.container.adding.Adding"
       allowed_attributes="setContentName add"
       permission="Zope.ManageContent" />

  <vfs:view
      name="Package"
      for="zope.app.interfaces.container.IAdding"
      factory="zope.app.vfs.services.package.PackageAdd"
      permission="Zope.ManageContent" />


  <vfs:view
      name="vfs"
      for="zope.app.interfaces.services.service.IServiceManager"
      permission="Zope.ManageContent" 
      allowed_interface="zope.publisher.interfaces.vfs.IVFSDirectoryPublisher" 
      factory="zope.app.vfs.services.service.ServiceManagerView" 
      />

  <vfs:view
      name="vfs"
      for="zope.app.interfaces.services.package.IPackages"
      permission="Zope.ManageContent" 
      allowed_interface="zope.publisher.interfaces.vfs.IVFSDirectoryPublisher" 
      factory="zope.app.vfs.services.package.PackagesView" 
      />

  <vfs:view
      name="vfs"
      for="zope.app.interfaces.services.package.IPackage"
      permission="Zope.ManageContent" 
      allowed_interface="zope.publisher.interfaces.vfs.IVFSDirectoryPublisher" 
      factory="zope.app.vfs.services.package.PackageView" 
      />

</zopeConfigure>


=== Added File Zope3/src/zope/app/vfs/services/package.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 Package Add View

$Id: package.py,v 1.1.2.1 2002/12/23 19:32:37 jim Exp $
"""
from zope.publisher.vfs import VFSView

from zope.event import publish
from zope.app.event.objectevent import ObjectCreatedEvent

from zope.app.interfaces.container import IAdding
from zope.app.services.package import Package


class PackageAdd(VFSView):
    "Provide a user interface for adding a Package content object"

    __used_for__ = IAdding

    def __call__(self):
        "Add a folder"
        content = Package()
        publish(self.context, ObjectCreatedEvent(content))
        return self.context.add(content)



"""Adding View for IPackage

$Id: package.py,v 1.1.2.1 2002/12/23 19:32:37 jim Exp $
"""
from zope.publisher.vfs import VFSView
from zope.app.vfs.container.adding import Adding
from zope.app.interfaces.services.package import IPackageAdding

class PackageAdding(Adding):

    __implements__ =  IPackageAdding, VFSView.__implements__


"""VFS-View for IPackages

$Id: package.py,v 1.1.2.1 2002/12/23 19:32:37 jim Exp $
"""
import datetime
zerotime = datetime.datetime.fromtimestamp(0)

from zope.component import getAdapter
from zope.app.interfaces.dublincore import IZopeDublinCore
from zope.app.vfs.container.view import \
     VFSContainerView

class PackagesView(VFSContainerView):
    """Specific Packages VFS view."""

    __implments__ = VFSContainerView.__implements__

    _directory_type = 'Package'

    def remove(self, name):
        'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
        pass # not applicable

    def writefile(self, name, mode, instream, start=0):
        'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
        pass # not applicable

    


"""VFS-View for IPackage

$Id: package.py,v 1.1.2.1 2002/12/23 19:32:37 jim Exp $
"""
import datetime
zerotime = datetime.datetime.fromtimestamp(0)

from zope.component import getAdapter
from zope.app.interfaces.dublincore import IZopeDublinCore
from zope.app.vfs.container.view import \
     VFSContainerView

class PackageView(VFSContainerView):
    """Specific Package VFS view."""

    __implments__ = VFSContainerView.__implements__

    _directory_type = 'Package'



=== Added File Zope3/src/zope/app/vfs/services/service.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 IServiceManager

$Id: service.py,v 1.1.2.1 2002/12/23 19:32:37 jim Exp $
"""
import datetime
zerotime = datetime.datetime.fromtimestamp(0)

from zope.publisher.vfs import VFSView
from zope.publisher.interfaces.vfs import \
     IVFSDirectoryPublisher

class ServiceManagerView(VFSView):
    """Specific ServiceManager VFS view."""

    __implments__ = IVFSDirectoryPublisher, VFSView.__implements__

    ############################################################
    # Implementation methods for interface
    # Zope.Publisher.VFS.IVFSDirectoryPublisher

    def exists(self, name):
        'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
        if name == 'Packages':
            return True
        return False

    def listdir(self, with_stats=0, pattern='*'):
        'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher' 
        return [('Packages', (16384+511, 0, 0, 0, "nouser", "nogroup", 0,
                            zerotime, zerotime, zerotime)) ]
    
    def mkdir(self, name, mode=777):
        'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
        pass

    def remove(self, name):
        'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
        pass

    def rmdir(self, name):
        'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
        pass

    def rename(self, old, new):
        'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
        pass

    def writefile(self, name, mode, instream, start=0):
        'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
        pass

    def check_writable(self, name):
        'See Zope.Publisher.VFS.IVFSDirectoryPublisher.IVFSDirectoryPublisher'
        return False


    ######################################
    # from: Zope.Publisher.VFS.IVFSObjectPublisher.IVFSObjectPublisher

    def isdir(self):
        'See Zope.Publisher.VFS.IVFSObjectPublisher.IVFSObjectPublisher'
        return True

    def isfile(self):
        'See Zope.Publisher.VFS.IVFSObjectPublisher.IVFSObjectPublisher'
        return False

    def stat(self):
        'See Zope.Publisher.VFS.IVFSObjectPublisher.IVFSObjectPublisher'
        return (16384+511, 0, 0, 0, "nouser", "nogroup", 4096,
                 zerotime, zerotime, zerotime)

    ######################################
    # from: Zope.Publisher.VFS.IVFSPublisher.IVFSPublisher

    def publishTraverse(self, request, name):
        'See Zope.Publisher.VFS.IVFSPublisher.IVFSPublisher'
        return None
    #
    ############################################################


=== Added File Zope3/src/zope/app/vfs/services/zpt.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: zpt.py,v 1.1.2.1 2002/12/23 19:32:37 jim Exp $
"""
from zope.publisher.vfs import VFSView

from zope.event import publish
from zope.app.event.objectevent import ObjectCreatedEvent

from zope.app.interfaces.services.package import IPackageAdding
from zope.app.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)



"""VFS-View for IZPTTemplate

VFS-view implementation for a ZPT Template. 

$Id: zpt.py,v 1.1.2.1 2002/12/23 19:32:37 jim Exp $
"""
from zope.publisher.vfs import VFSFileView

class ZPTTemplateView(VFSFileView):

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

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