[Zope3-checkins] CVS: Zope3/src/zope/app/i18nfile - configure.zcml:1.6 i18nfile.py:1.3 i18nimage.py:1.3 interfaces.py:1.3

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Mar 18 22:18:12 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/i18nfile
In directory cvs.zope.org:/tmp/cvs-serv2488/src/zope/app/i18nfile

Modified Files:
	configure.zcml i18nfile.py i18nimage.py interfaces.py 
Log Message:


Modernized the File and Image API to rely more heavily on schemas instead of
accessor and mutator methods. Removed a lot of unnecessary cruft from the
object classes and their views.


=== Zope3/src/zope/app/i18nfile/configure.zcml 1.5 => 1.6 ===
--- Zope3/src/zope/app/i18nfile/configure.zcml:1.5	Sat Mar 13 18:00:57 2004
+++ Zope3/src/zope/app/i18nfile/configure.zcml	Thu Mar 18 22:17:41 2004
@@ -51,11 +51,11 @@
         />
     <require
         permission="zope.View"
-        interface="zope.app.file.interfaces.IReadFile"
+        interface="zope.app.file.interfaces.IFile"
         />
     <require
         permission="zope.ManageContent"
-        interface="zope.app.file.interfaces.IWriteFile"
+        set_schema="zope.app.file.interfaces.IFile"
         />
     <require
         permission="zope.View"
@@ -78,12 +78,12 @@
         />
     <require
         permission="zope.View"
-        interface="zope.app.file.interfaces.IReadFile"
+        interface="zope.app.file.interfaces.IFile"
         attributes="getImageSize"
         />
     <require
         permission="zope.ManageContent"
-        interface="zope.app.file.interfaces.IWriteFile"
+        set_schema="zope.app.file.interfaces.IFile"
         />
     <require
         permission="zope.View"


=== Zope3/src/zope/app/i18nfile/i18nfile.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/i18nfile/i18nfile.py:1.2	Tue Feb 24 11:50:07 2004
+++ Zope3/src/zope/app/i18nfile/i18nfile.py	Thu Mar 18 22:17:41 2004
@@ -14,15 +14,14 @@
 """
 $Id$
 """
-
-import persistence
+from persistent import Persistent
 from zope.interface import implements
 from zope.publisher.browser import FileUpload
 from zope.app.file.file import File
 
 from interfaces import II18nFile
 
-class I18nFile(persistence.Persistent):
+class I18nFile(Persistent):
     """I18n aware file object.  It contains a number of File objects --
     one for each language.
     """
@@ -34,13 +33,7 @@
         self.defaultLanguage = defaultLanguage
         self.setData(data, language=defaultLanguage)
 
-        if contentType is None:
-            self.setContentType('')
-        else:
-            self.setContentType(contentType)
-
-    def __len__(self):
-        return self.getSize()
+        self.contentType = contentType or ''
 
     def _create(self, data):
         """Create a new subobject of the appropriate type.  Should be
@@ -70,37 +63,13 @@
             self._p_changed = 1
         return file
 
-    def setContentType(self, contentType):
-        '''See interface IFile'''
-        self._contentType = contentType
-
-    def getContentType(self):
-        '''See interface IFile'''
-        return self._contentType
-
-    contentType = property(getContentType, setContentType)
-
-    def edit(self, data, contentType=None, language=None):
-        '''See interface IFile'''
-
-        # XXX This seems broken to me, as setData can override the
-        # content type explicitly passed in.
-
-        if contentType is not None:
-            self.setContentType(contentType)
-        if isinstance(data, FileUpload) and not data.filename:
-            data = None          # Ignore empty files
-        if data is not None:
-            self.setData(data, language)
-
     def getData(self, language=None):
-        '''See interface IFile'''
-        return self._get(language).getData()
+        return self._get(language).data
 
     def setData(self, data, language=None):
-        '''See interface IFile'''
-        self._get_or_add(language).setData(data)
+        self._get_or_add(language).data = data
 
+    # See IFile.
     data = property(getData, setData)
 
     def getSize(self, language=None):


=== Zope3/src/zope/app/i18nfile/i18nimage.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/i18nfile/i18nimage.py:1.2	Tue Feb 24 11:50:07 2004
+++ Zope3/src/zope/app/i18nfile/i18nimage.py	Thu Mar 18 22:17:41 2004
@@ -41,7 +41,7 @@
             # work.
             contentType = getImageInfo(self.getData(language))[0]
             if contentType:
-                self.setContentType(contentType)
+                self.contentType = contentType
 
     def getImageSize(self, language=None):
         '''See interface IImage'''


=== Zope3/src/zope/app/i18nfile/interfaces.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/i18nfile/interfaces.py:1.2	Tue Feb 24 11:50:07 2004
+++ Zope3/src/zope/app/i18nfile/interfaces.py	Thu Mar 18 22:17:41 2004
@@ -14,7 +14,6 @@
 """
 $Id$
 """
-
 from zope.i18n.interfaces import II18nAware
 from zope.app.file.interfaces import IFile, IImage
 




More information about the Zope3-Checkins mailing list