r13545 - in Products.Archetypes/branches/1.6: . Products/Archetypes Products/Archetypes/tests
"David Glick" <[email protected]> Wed, 30 Mar 2011 20:10:35 +0000
| Newsgroups | gmane.comp.web.zope.plone.archetypes.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: davisagli
Date: Wed Mar 30 20:10:35 2011
New Revision: 13545
Modified:
Products.Archetypes/branches/1.6/CHANGES.txt
Products.Archetypes/branches/1.6/Products/Archetypes/Field.py
Products.Archetypes/branches/1.6/Products/Archetypes/tests/test_fields.py
Log:
fix bug where default_content_type was not respected
Modified: Products.Archetypes/branches/1.6/CHANGES.txt
==============================================================================
--- Products.Archetypes/branches/1.6/CHANGES.txt (original)
+++ Products.Archetypes/branches/1.6/CHANGES.txt Wed Mar 30 20:10:35 2011
@@ -4,6 +4,10 @@
1.6.6 - 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/branches/1.6/Products/Archetypes/Field.py
==============================================================================
--- Products.Archetypes/branches/1.6/Products/Archetypes/Field.py (original)
+++ Products.Archetypes/branches/1.6/Products/Archetypes/Field.py Wed Mar 30 20:10:35 2011
@@ -1075,6 +1075,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/branches/1.6/Products/Archetypes/tests/test_fields.py
==============================================================================
--- Products.Archetypes/branches/1.6/Products/Archetypes/tests/test_fields.py (original)
+++ Products.Archetypes/branches/1.6/Products/Archetypes/tests/test_fields.py Wed Mar 30 20:10:35 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