2 def eml_to_mht(db, cl, nodeid, newvalues):
3 '''This reactor fires whenever a new file entity is created.
5 If the file is of type message/rfc822, we tack onthe extension .eml.
7 The reason for this is that Microsoft Internet Explorer will not open
8 things with a .eml attachment, as they deem it 'unsafe'. Worse yet,
9 they'll just give you an incomprehensible error message. For more
10 information, please see:
12 http://support.microsoft.com/default.aspx?scid=kb;EN-US;825803
14 Their suggested work around is (excerpt):
16 WORKAROUND
18 To work around this behavior, rename the .EML file that the URL
19 links to so that it has a .MHT file name extension, and then update
20 the URL to reflect the change to the file name. To do this:
22 1. In Windows Explorer, locate and then select the .EML file that
23 the URL links.
24 2. Right-click the .EML file, and then click Rename.
25 3. Change the file name so that the .EML file uses a .MHT file name
26 extension, and then press ENTER.
27 4. Updated the URL that links to the file to reflect the new file
28 name extension.
30 So... we do that. :)'''
31 if newalues.get('type', '').lower() == "message/rfc822":
32 if newvalues.has_key('name'):
33 newvalues['name'] = 'email.mht'
34 name = newvalues['name']
35 if name.endswith('.eml'):
36 name = name[:-4]
37 newvalues['name'] = name + '.mht'
39 def init(db):
40 db.file.react('create', eml_to_mht)