[Zope3-checkins] CVS: Zope3/src/zope/app/vfs/content - __init__.py:1.2 configure.zcml:1.2 dtmlpageadd.py:1.2 dtmlpageview.py:1.2 file.py:1.2 folder.py:1.2 sql.py:1.2 zpt.py:1.2

Jim Fulton jim@zope.com
Wed, 25 Dec 2002 09:14:00 -0500


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

Added Files:
	__init__.py configure.zcml dtmlpageadd.py dtmlpageview.py 
	file.py folder.py sql.py zpt.py 
Log Message:
Grand renaming:

- Renamed most files (especially python modules) to lower case.

- Moved views and interfaces into separate hierarchies within each
  project, where each top-level directory under the zope package
  is a separate project.

- Moved everything to src from lib/python.

  lib/python will eventually go away. I need access to the cvs
  repository to make this happen, however.

There are probably some bits that are broken. All tests pass
and zope runs, but I haven't tried everything. There are a number
of cleanups I'll work on tomorrow.



=== Zope3/src/zope/app/vfs/content/__init__.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:13:59 2002
+++ Zope3/src/zope/app/vfs/content/__init__.py	Wed Dec 25 09:13:29 2002
@@ -0,0 +1,2 @@
+#
+# This file is necessary to make this directory a package.


=== Zope3/src/zope/app/vfs/content/configure.zcml 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:13:59 2002
+++ Zope3/src/zope/app/vfs/content/configure.zcml	Wed Dec 25 09:13:29 2002
@@ -0,0 +1,91 @@
+<zopeConfigure
+   xmlns="http://namespaces.zope.org/zope"
+   xmlns:vfs="http://namespaces.zope.org/vfs">
+
+<!-- DTML -->
+
+  <vfs:view name="vfs" 
+       for="zope.app.content.dtmlpage.IDTMLPage"
+       permission="zope.View" 
+       allowed_interface="zope.publisher.interfaces.vfs.IVFSFilePublisher"
+       factory="zope.app.vfs.content.dtmlpageview.DTMLPageView" />
+
+  <vfs:view
+      name=".dtml"
+      for="zope.app.interfaces.container.IAdding"
+      factory="zope.app.vfs.content.dtmlpageadd.DTMLPageAdd"
+      permission="zope.ManageContent" />
+
+
+<!-- ZPT -->
+
+  <vfs:view name="vfs" 
+       for="zope.app.content.zpt.IZPTPage"
+       permission="zope.View" 
+       allowed_interface="zope.publisher.interfaces.vfs.IVFSFilePublisher"
+       factory="zope.app.vfs.content.zpt.ZPTPageView" />
+
+  <vfs:view
+      name=".pt"
+      for="zope.app.interfaces.container.IAdding"
+      factory="zope.app.vfs.content.zpt.ZPTPageAdd"
+      permission="zope.ManageContent" />
+
+  <vfs:view
+      name=".zpt"
+      for="zope.app.interfaces.container.IAdding"
+      factory="zope.app.vfs.content.zpt.ZPTPageAdd"
+      permission="zope.ManageContent" />
+
+<!-- Folder -->
+
+  <vfs:view
+      name="Folder"
+      for="zope.app.interfaces.container.IAdding"
+      factory="zope.app.vfs.content.folder.FolderAdd"
+      permission="zope.ManageContent" />
+
+  <vfs:view
+      name="vfs"
+      for="zope.app.interfaces.content.folder.IFolder"
+      permission="zope.ManageContent" 
+      allowed_interface="zope.publisher.interfaces.vfs.IVFSDirectoryPublisher" 
+      factory="zope.app.vfs.content.folder.FolderView" 
+      />
+
+<!-- SQL -->
+
+  <vfs:view name="vfs" 
+       for="zope.app.content.sql.ISQLScript"
+       permission="zope.View" 
+       allowed_interface="zope.publisher.interfaces.vfs.IVFSFilePublisher"
+       factory="zope.app.vfs.content.sql.SQLScriptView" />
+
+  <vfs:view
+      name=".sql"
+      for="zope.app.interfaces.container.IAdding"
+      factory="zope.app.vfs.content.sql.SQLScriptAdd"
+      permission="zope.ManageContent" />
+
+  <vfs:view
+      name=".zsql"
+      for="zope.app.interfaces.container.IAdding"
+      factory="zope.app.vfs.content.sql.SQLScriptAdd"
+      permission="zope.ManageContent" />
+
+<!-- File -->
+
+  <vfs:view name="vfs" 
+       for="zope.app.interfaces.content.file.IFile"
+       permission="zope.View" 
+       allowed_interface="zope.publisher.interfaces.vfs.IVFSFilePublisher"
+       factory="zope.app.vfs.content.file.FileView" />
+
+  <!-- Generic File Adder -->
+  <vfs:view
+      name="."
+      for="zope.app.interfaces.container.IAdding"
+      factory="zope.app.vfs.content.file.FileAdd"
+      permission="zope.ManageContent" />
+
+</zopeConfigure>


=== Zope3/src/zope/app/vfs/content/dtmlpageadd.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:13:59 2002
+++ Zope3/src/zope/app/vfs/content/dtmlpageadd.py	Wed Dec 25 09:13:29 2002
@@ -0,0 +1,41 @@
+##############################################################################
+#
+# 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 DTMLPage Add View
+
+$Id$
+"""
+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.content.dtmlpage import DTMLPage
+
+
+class DTMLPageAdd(VFSView):
+    "Provide a user interface for adding a DTMLPage content object"
+
+    __used_for__ = IAdding
+
+    def __call__(self, mode, instream, start):
+        content = DTMLPage()
+        try:
+            instream.seek(start)
+        except:
+            pass
+        content.setSource(instream.read())
+
+        publish(self.context, ObjectCreatedEvent(content))
+        return self.context.add(content)


=== Zope3/src/zope/app/vfs/content/dtmlpageview.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:13:59 2002
+++ Zope3/src/zope/app/vfs/content/dtmlpageview.py	Wed Dec 25 09:13:29 2002
@@ -0,0 +1,28 @@
+##############################################################################
+#
+# 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 IDTMLPage
+
+VFS-view implementation for a DTML Page.
+
+$Id$
+"""
+from zope.publisher.vfs import VFSFileView
+
+class DTMLPageView(VFSFileView):
+
+    def _setData(self, data):
+        self.context.setSource(data)
+
+    def _getData(self):
+        return self.context.getSource()


=== Zope3/src/zope/app/vfs/content/file.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:13:59 2002
+++ Zope3/src/zope/app/vfs/content/file.py	Wed Dec 25 09:13:29 2002
@@ -0,0 +1,63 @@
+##############################################################################
+#
+# 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 File Add View
+
+$Id$
+"""
+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.content.file import File
+
+
+class FileAdd(VFSView):
+    "Provide a user interface for adding a File content object"
+
+    __used_for__ = IAdding
+
+    def __call__(self, mode, instream, start):
+        "Add a contact"
+        content = File()
+        try:
+            instream.seek(start)
+        except:
+            pass
+        content.setData(instream.read())
+
+        publish(self.context, ObjectCreatedEvent(content))
+        return self.context.add(content)
+
+
+
+"""VFS-View for IFile
+
+VFS-view implementation for a generic file.
+
+$Id$
+"""
+from zope.publisher.vfs import VFSFileView
+
+class FileView(VFSFileView):
+
+    def _setData(self, data):
+        self.context.setData(data)
+
+    def _getData(self):
+        return self.context.getData()
+
+    def _getSize(self):
+        return self.context.getSize()


=== Zope3/src/zope/app/vfs/content/folder.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:13:59 2002
+++ Zope3/src/zope/app/vfs/content/folder.py	Wed Dec 25 09:13:29 2002
@@ -0,0 +1,93 @@
+##############################################################################
+#
+# 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 Folder Add View
+
+$Id$
+"""
+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.content.folder import Folder
+
+
+class FolderAdd(VFSView):
+    "Provide a user interface for adding a Folder content object"
+
+    __used_for__ = IAdding
+
+    def __call__(self):
+        "Add a folder"
+        content = Folder()
+        publish(self.context, ObjectCreatedEvent(content))
+        return self.context.add(content)
+
+
+
+"""VFS-View for IFolder
+
+$Id$
+"""
+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 FolderView(VFSContainerView):
+    """Specific Folder VFS view."""
+
+    __implments__ = VFSContainerView.__implements__
+
+    _directory_type = 'Folder'
+
+    def _getServiceManagerStat(self):
+        """Get the stat information of the local service manager."""
+        # XXX ServiceManager does not use the DublinCore to keep track of its
+        # creation and modification times, so we use the data of the Folder
+        # right now.
+        dc = getAdapter(self.context, IZopeDublinCore)
+        if dc is not None:
+            created = dc.created
+            modified = dc.modified
+        else:
+            created = zerotime
+            modified = zerotime
+        if modified is None:
+            modified = created
+        dir_mode = 16384 + 504
+        uid = "nouser"
+        gid = "nogroup"
+        return (dir_mode, 0, 0, 0, uid, gid, 4096, modified, modified,
+                created)
+
+
+    def exists(self, name):
+        'See IVFSDirectoryPublisher'
+        if self.context.hasServiceManager() and name == '++etc++Services':
+            return True
+        return super(FolderView, self).exists(name)
+
+
+    def listdir(self, with_stats=0, pattern='*'):
+        'See IVFSDirectoryPublisher'
+        result = super(FolderView, self).listdir(with_stats, pattern)
+        if self.context.hasServiceManager():
+            result = [('++etc++Services', self._getServiceManagerStat())] \
+                     + result
+        return result


=== Zope3/src/zope/app/vfs/content/sql.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:13:59 2002
+++ Zope3/src/zope/app/vfs/content/sql.py	Wed Dec 25 09:13:29 2002
@@ -0,0 +1,59 @@
+##############################################################################
+#
+# 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 SQLScript Add View
+
+$Id$
+"""
+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.content.sql import SQLScript
+
+
+class SQLScriptAdd(VFSView):
+    "Provide a user interface for adding a SQLScript content object"
+
+    __used_for__ = IAdding
+
+    def __call__(self, mode, instream, start):
+        content = SQLScript()
+        try:
+            instream.seek(start)
+        except:
+            pass
+        content.setSource(instream.read())
+
+        publish(self.context, ObjectCreatedEvent(content))
+        return self.context.add(content)
+
+
+
+"""VFS-View for ISQLScript
+
+VFS-view implementation for a ZPT Page.
+
+$Id$
+"""
+from zope.publisher.vfs import VFSFileView
+
+class SQLScriptView(VFSFileView):
+
+    def _setData(self, data):
+        self.context.setSource(data)
+
+    def _getData(self):
+        return self.context.getSource()


=== Zope3/src/zope/app/vfs/content/zpt.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:13:59 2002
+++ Zope3/src/zope/app/vfs/content/zpt.py	Wed Dec 25 09:13:29 2002
@@ -0,0 +1,59 @@
+##############################################################################
+#
+# 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 ZPTPage Add View
+
+$Id$
+"""
+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.content.zpt import ZPTPage
+
+
+class ZPTPageAdd(VFSView):
+    "Provide a user interface for adding a ZPTPage content object"
+
+    __used_for__ = IAdding
+
+    def __call__(self, mode, instream, start):
+        content = ZPTPage()
+        try:
+            instream.seek(start)
+        except:
+            pass
+        content.setSource(unicode(instream.read()))
+
+        publish(self.context, ObjectCreatedEvent(content))
+        return self.context.add(content)
+
+
+
+"""VFS-View for IZPTPage
+
+VFS-view implementation for a ZPT Page.
+
+$Id$
+"""
+from zope.publisher.vfs import VFSFileView
+
+class ZPTPageView(VFSFileView):
+
+    def _setData(self, data):
+        self.context.setSource(data)
+
+    def _getData(self):
+        return self.context.getSource()