[Zope-CVS] CVS: Products/Ape/apelib/zope2 - classifier.py:1.2 ofsserial.py:1.2

Shane Hathaway shane@zope.com
Sat, 29 Mar 2003 22:11:26 -0500


Update of /cvs-repository/Products/Ape/apelib/zope2
In directory cvs.zope.org:/tmp/cvs-serv14802/apelib/zope2

Modified Files:
	classifier.py ofsserial.py 
Log Message:
Improved handling of the content_type attribute of OFS.File and OFS.Image
objects.  The content_type will now be preserved once set.


=== Products/Ape/apelib/zope2/classifier.py 1.1.1.1 => 1.2 ===
--- Products/Ape/apelib/zope2/classifier.py:1.1.1.1	Sat Mar 15 18:44:43 2003
+++ Products/Ape/apelib/zope2/classifier.py	Sat Mar 29 22:11:26 2003
@@ -25,7 +25,8 @@
 from apelib.core.exceptions import DeserializationError
 
 # guess_extension() is useful but it's unoptimized and sometimes
-# chooses strange extensions.  fixed_extensions is faster and contains
+# chooses strange extensions.  fixed_extensions does nothing other than
+# suggest a filename extension given a content type.  It contains
 # some better defaults.
 fixed_extensions = {
     'text/plain': '.txt',


=== Products/Ape/apelib/zope2/ofsserial.py 1.1.1.1 => 1.2 ===
--- Products/Ape/apelib/zope2/ofsserial.py:1.1.1.1	Sat Mar 15 18:44:44 2003
+++ Products/Ape/apelib/zope2/ofsserial.py	Sat Mar 29 22:11:26 2003
@@ -66,7 +66,13 @@
 
     def deserialize(self, object, event, state):
         data, size = object._read_data(state)
-        content_type = object._get_content_type(state, data, object.__name__)
+        if not object.__dict__.get('content_type'):
+            # Guess the content type.
+            content_type = object._get_content_type(
+                state, data, object.__name__)
+        else:
+            # The properties serializer is authoritative.  Defer to it.
+            content_type = None
         object.update_data(data, content_type, size)
         event.notifyDeserialized('data', object.data)