[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/File - File.py:1.10 IFile.py:1.10

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


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

Modified Files:
	File.py IFile.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/App/OFS/Content/File/File.py 1.9 => 1.10 ===
--- Zope3/lib/python/Zope/App/OFS/Content/File/File.py:1.9	Wed Dec  4 15:49:38 2002
+++ Zope3/lib/python/Zope/App/OFS/Content/File/File.py	Fri Dec 20 04:25:39 2002
@@ -16,14 +16,19 @@
 $Id$
 """
 from types import StringType, UnicodeType, NoneType
+import datetime
+zerotime = datetime.datetime.fromtimestamp(0)
 
 from Persistence import Persistent
 from Transaction import get_transaction
 
-from Zope.App.OFS.Content.File.FileChunk import FileChunk
+from Zope.ComponentArchitecture import getAdapter
 from Zope.Publisher.Browser.BrowserRequest import FileUpload
 
+from Zope.App.DublinCore.IZopeDublinCore import IZopeDublinCore
 from Zope.App.OFS.Annotation.IAnnotatable import IAnnotatable
+
+from Zope.App.OFS.Content.File.FileChunk import FileChunk
 from Zope.App.OFS.Content.File.IFile import IFile, IReadFile
 
 # set the size of the chunks


=== Zope3/lib/python/Zope/App/OFS/Content/File/IFile.py 1.9 => 1.10 ===
--- Zope3/lib/python/Zope/App/OFS/Content/File/IFile.py:1.9	Mon Dec  9 11:28:58 2002
+++ Zope3/lib/python/Zope/App/OFS/Content/File/IFile.py	Fri Dec 20 04:25:39 2002
@@ -11,16 +11,14 @@
 # FOR A PARTICULAR PURPOSE.
 # 
 ##############################################################################
-"""
+"""Basic File interfaces.
 
 $Id$
 """
-
 from Interface import Interface
-from Zope.App.OFS.Content.IFileContent import IFileContent
 import Zope.Schema
 
-class IReadFile(IFileContent):
+class IReadFile(Interface):
     
     contentType = Zope.Schema.BytesLine(
         title = u'Content Type',
@@ -35,19 +33,14 @@
         )
 
     def getData():
-        """Returns the bits (data) of the File itself."""
-
+        """Return the contained data of the object."""
 
     def getContentType():
         """Returns the content type of the file using mime-types syntax."""
 
-
     def getSize():
-        """Return the size of the file.
+        """Return the byte-size of the data of the object."""
 
-        Note that only the file's content is counted and not the entire
-        Python object.
-        """
 
 class IWriteFile(Interface):
 
@@ -59,10 +52,8 @@
            through the data, it is good to leave the argument optional.
         """
 
-
     def setData(data):
-        """Sets ONLY the data without changing the content type."""
-
+        """Rewrite the 'file'."""
 
     def setContentType(contentType):
         """Sets the content type of the file."""