[Zope3-checkins] CVS: Zope3/src/zope/app/file/browser - file.py:1.6 image.py:1.3 image_edit.pt:1.3

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


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

Modified Files:
	file.py image.py image_edit.pt 
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/file/browser/file.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/file/browser/file.py:1.5	Thu Mar 18 12:01:08 2004
+++ Zope3/src/zope/app/file/browser/file.py	Thu Mar 18 22:17:39 2004
@@ -18,23 +18,21 @@
 from zope.app.form.browser import BytesAreaWidget
 from zope.app.form import CustomWidgetFactory
 
-__metaclass__ = type
-
-class FileView:
+class FileView(object):
 
     def show(self):
         """Call the File"""
         request = self.request
         if request is not None:
             request.response.setHeader('Content-Type',
-                                       self.context.getContentType())
+                                       self.context.contentType)
             request.response.setHeader('Content-Length',
                                        self.context.getSize())
 
-        return self.context.getData()
+        return self.context.data
 
 
-class FileTextEdit:
+class FileTextEdit(object):
     """File editing mix-in that uses a file-upload widget.
     """
 


=== Zope3/src/zope/app/file/browser/image.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/file/browser/image.py:1.2	Tue Feb 24 11:49:48 2004
+++ Zope3/src/zope/app/file/browser/image.py	Thu Mar 18 22:17:39 2004
@@ -16,18 +16,14 @@
 $Id$
 """
 from zope.app.size import byteDisplay
-from zope.app.event.objectevent import ObjectModifiedEvent
-from zope.app.event import publish
-from zope.app.publisher.browser import BrowserView
 
-class ImageData(BrowserView):
+class ImageData(object):
 
     def __call__(self):
         image = self.context
         if self.request is not None:
-            self.request.response.setHeader('content-type',
-                                            image.getContentType())
-        return image.getData()
+            self.request.response.setHeader('content-type', image.contentType)
+        return image.data
 
     def tag(self, height=None, width=None, alt=None,
             scale=0, xscale=0, yscale=0, css_class=None, **args):
@@ -85,7 +81,7 @@
         return '%s />' % result
 
 
-class ImageUpload:
+class ImageUpload(object):
     """Image edit view mix-in that provides access to image size info"""
 
     def size(self):
@@ -97,31 +93,3 @@
         return "%s x %s pixels, %s" % (
                 sx, sy, byteDisplay(self.context.getSize())
                 )
-
-    def apply_update(self, data):
-        """Apply user inputs
-
-        These inputs have already been validated.
-
-        Return a boolean indicating whether we changed anything,
-        """
-
-        unchanged = True
-
-        # if we can compute the content type from the raw data, then
-        # that overrides what the user provided, so set the content
-        # type first.
-
-        contentType = data.get('contentType')
-        if contentType and contentType != self.context.contentType:
-            self.context.contentType = contentType
-            unchanged = False
-
-        if 'data' in data:
-            self.context.data = data['data']
-            unchanged = False
-
-        if not unchanged:
-            publish(self.context, ObjectModifiedEvent(self.context))
-
-        return unchanged


=== Zope3/src/zope/app/file/browser/image_edit.pt 1.2 => 1.3 ===
--- Zope3/src/zope/app/file/browser/image_edit.pt:1.2	Tue Feb 24 11:49:48 2004
+++ Zope3/src/zope/app/file/browser/image_edit.pt	Thu Mar 18 22:17:39 2004
@@ -14,9 +14,6 @@
       </tr>
     </table>
 
-    <input type="submit" name="save" value="Save Changes" 
-        i18n:attributes="value save-changes-button"/>
-
   </form>
 
   </div>




More information about the Zope3-Checkins mailing list