TextField's handling of mimetypes is dumb

"Martin Aspeli" <[email protected]>
Newsgroups gmane.comp.web.zope.plone.archetypes.devel
Message-ID <op.s2dhfeapfyd109@vigor54>
Hi,

I'm making a new transform which I call "web-intelligent plain text"  
(better name suggestions welcome). Basically, this is the "forum" style of  
text/plain: Upon transform, links and mail addresses become clickable (<a  
href="http://test.com">test.com</a>), newlines become <br />s and  
indentation become &nbsp; so that you can format your text to a certain  
extent. I will release this into the collective, by the way, so hopefully  
it'll be useful to others.

To make this work, I've registered a new mimetype with the  
mimetypes_registry called text/x-web-intelligent, and then I've set my  
fields to have default_output_type='text/html',  
default_content_type='text/x-web-intelligent' and  
allowable_content_types=('text/x-web-intelligent',). The transform then  
has text/x-web-intelligent as the input type and text/html as the output  
type.

This works OK TTW, where the mimetype is explicitly passed along in the  
request from base_edit. But it truly pisses me off that when I call the  
mutator from code, FileField.set() delegates to  
mimetypes_registry.classify(), which falls back on 'text/plain', and  
that's the way it stays. That's not even in allowable_content_types, and  
it means my transform fails to trigger. Instead, I have to remember to do:

	instance.setMyField('Some text with a link like http://link.com',  
mimetype='text/x-web-intelligent)

Why can't it default to the default_content_type? This is a property on  
the field, not the widget, which implies it should apply at the field  
level, not just TTW.

Martin

-- 
(muted)



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.