r13546 - in Products.Archetypes/trunk: . Products/Archetypes Products/Archetypes/tests

"David Glick" <[email protected]> Wed, 30 Mar 2011 20:13:29 +0000
Newsgroups gmane.comp.web.zope.plone.archetypes.cvs
Message-ID <[email protected]>
Author: davisagli
Date: Wed Mar 30 20:13:28 2011
New Revision: 13546

Modified:
   Products.Archetypes/trunk/   (props changed)
   Products.Archetypes/trunk/CHANGES.txt
   Products.Archetypes/trunk/Products/Archetypes/   (props changed)
   Products.Archetypes/trunk/Products/Archetypes/Field.py
   Products.Archetypes/trunk/Products/Archetypes/tests/test_fields.py
Log:
merge r13545 from 1.6 branch

Modified: Products.Archetypes/trunk/CHANGES.txt
==============================================================================
--- Products.Archetypes/trunk/CHANGES.txt	(original)
+++ Products.Archetypes/trunk/CHANGES.txt	Wed Mar 30 20:13:28 2011
@@ -4,6 +4,10 @@
 1.7.4 - Unreleased
 ------------------
 
+- Fix bug where a TextField's default_content_type was not respected when
+  wrapping a non-BaseUnit value.
+  [davisagli]
+
 - Fixed test setup to work with ZCA-based GenericSetup profile registry.
   [davisagli]
 

Modified: Products.Archetypes/trunk/Products/Archetypes/Field.py
==============================================================================
--- Products.Archetypes/trunk/Products/Archetypes/Field.py	(original)
+++ Products.Archetypes/trunk/Products/Archetypes/Field.py	Wed Mar 30 20:13:28 2011
@@ -1077,6 +1077,11 @@
         obj = self._make_file(self.getName(), title='',
                               file=value, instance=instance)
         setattr(obj, 'filename', filename)
+        if IBaseUnit.providedBy(obj):
+            if mimetype:
+                obj.setContentType(instance, mimetype)
+        else:
+            setattr(obj, 'content_type', mimetype)
         setattr(obj, 'content_type', mimetype)
         try:
             delattr(obj, 'title')

Modified: Products.Archetypes/trunk/Products/Archetypes/tests/test_fields.py
==============================================================================
--- Products.Archetypes/trunk/Products/Archetypes/tests/test_fields.py	(original)
+++ Products.Archetypes/trunk/Products/Archetypes/tests/test_fields.py	Wed Mar 30 20:13:28 2011
@@ -401,6 +401,13 @@
         encoding = field.getRaw(self.portal, raw=1).original_encoding
         self.assertEqual(encoding, 'latin')
 
+    def test_mimetype(self):
+        dummy = self.makeDummy()
+        field = TextField('test', default_content_type='text/html')
+        dummy.test = ''
+        mimetype = field.getContentType(dummy)
+        self.assertEqual('text/html', mimetype)
+
 
 class DownloadTest(ATSiteTestCase):
 

------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf