comparison detectors/emailauditor.py @ 4627:6b32e9dac625

Restore sample detectors removed by 07c5d833dcb2 (issue2550574)
author Thomas Arendsen Hein <thomas@intevation.de>
date Wed, 16 May 2012 11:17:03 +0200
parents
children 0942fe89e82e
comparison
equal deleted inserted replaced
4626:e3cd5fcf710b 4627:6b32e9dac625
1
2 def eml_to_mht(db, cl, nodeid, newvalues):
3 '''This auditor fires whenever a new file entity is created.
4
5 If the file is of type message/rfc822, we tack onthe extension .eml.
6
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:
11
12 http://support.microsoft.com/default.aspx?scid=kb;EN-US;825803
13
14 Their suggested work around is (excerpt):
15
16 WORKAROUND
17
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:
21
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.
29
30 So... we do that. :)'''
31 if newvalues.get('type', '').lower() == "message/rfc822":
32 if not newvalues.has_key('name'):
33 newvalues['name'] = 'email.mht'
34 return
35 name = newvalues['name']
36 if name.endswith('.eml'):
37 name = name[:-4]
38 newvalues['name'] = name + '.mht'
39
40 def init(db):
41 db.file.audit('create', eml_to_mht)
42

Roundup Issue Tracker: http://roundup-tracker.org/