[Zope3-checkins] CVS: Zope3/lib/python/Zope/Server/VFS - OSFileSystem.py:1.4

Stephan Richter srichter@cbu.edu
Fri, 20 Dec 2002 04:26:16 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Server/VFS
In directory cvs.zope.org:/tmp/cvs-serv31450/Zope/Server/VFS

Modified Files:
	OSFileSystem.py 
Log Message:
Refactoring and fixing VFS and FTP

I am glad to make this commit that fixes up a lot of the FTP
implementation. I fixed the behavior of many of the FTP commands,
including LIST, SIZE, and CWD.

I moved the original VFSFile/DirectoryView into abstract classes and wrote
a special implementation for each content type, which makes the code much
more flexible.

Also I finally implemented a smart way of adding files via VFS through
file extension introspection, based on Jim's ExtensionViewName proposal.

I am adding documentation in the DevelCookbook right now and will later
add a README file.

TODOs:

- make VFS View names flexible, so that file extensions specify views.

- Simplify ZCML directives, so that one can add new extensions for Add views
  quicker. A solution might look like that:

      <vfs:view
          name=".dtml"
          for="Zope.App.OFS.Container.IAdding."
          factory=".DTMLPageAdd."
          permission="Zope.ManageContent">
        <vfs:extension name=".html" />
        <vfs:extension name=".xul" /> 
        <vfs:extension name=".xml" /> 
        ...
      </vfs:view>
			   
  This method would also be good for defining a default fiel extension.

- Show an object with its default file extension.
								     


=== Zope3/lib/python/Zope/Server/VFS/OSFileSystem.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/Server/VFS/OSFileSystem.py:1.3	Mon Nov 11 09:36:04 2002
+++ Zope3/lib/python/Zope/Server/VFS/OSFileSystem.py	Fri Dec 20 04:25:45 2002
@@ -11,14 +11,16 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
+"""Filesystem implementation for a real (unix-like) OS filesystem.
 
 $Id$
 """
 import os
 import re
 import stat
+import datetime
 import fnmatch
+fromts = datetime.datetime.fromtimestamp
 
 from IPosixFileSystem import IPosixFileSystem
 
@@ -136,7 +138,8 @@
     def stat(self, path):
         'See Zope.Server.VFS.IReadFileSystem.IReadFileSystem'
         p = self.translate(path)
-        return os.stat(p)
+        stat = os.stat(p)
+        return stat[0:6], fromts(stat[7]), fromts(stat[8]), fromts(stat[9])
 
 
     ######################################
@@ -234,6 +237,7 @@
 
 def safe_stat(path):
     try:
-        return os.stat(path)
+        stat = os.stat(p)
+        return stat[0, 6], fromts(stat[7]), fromts(stat[8]), fromts(stat[9])
     except OSError:
         return None