[Erp5-report] r14497 - in /erp5/trunk/utils/oood: mimemapper.py oood.conf
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue May 15 16:30:35 CEST 2007
Author: bartek
Date: Tue May 15 16:30:35 2007
New Revision: 14497
URL: http://svn.erp5.org?rev=14497&view=rev
Log:
customizeable allowed target list - in oood.conf you can specify which formats to use, or which formats to skip
Modified:
erp5/trunk/utils/oood/mimemapper.py
erp5/trunk/utils/oood/oood.conf
Modified: erp5/trunk/utils/oood/mimemapper.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/mimemapper.py?rev=14497&r1=14496&r2=14497&view=diff
==============================================================================
--- erp5/trunk/utils/oood/mimemapper.py (original)
+++ erp5/trunk/utils/oood/mimemapper.py Tue May 15 16:30:35 2007
@@ -319,6 +319,37 @@
'label':'PDF - Portable Document Format',
},
}
+
+ def __init__(self):
+ self.filterDocumentType()
+
+ def filterDocumentType(self):
+ """
+ This method is run upon init; it filters entries in document_type_dict (the dictionary which is used to build
+ allowed_target_item_list) according to what is specified in oood.conf file,
+ so that the system administrator can limit the list of target format to what is really
+ needed.
+ """
+ conf = config.config
+ for document_type in self.document_type_dict.keys():
+ section = document_type.title()
+ use_formats = conf.has_option(section, 'use_formats') and conf.get(section, 'use_formats') or 'All'
+ if use_formats.lower() == 'all':
+ use_formats = None
+ else:
+ use_formats = [s.strip() for s in use_formats.split(',')]
+ skip_formats = conf.has_option(section, 'skip_formats') and conf.get(section, 'skip_formats') or 'None'
+ if skip_formats.lower() == 'all':
+ skip_formats = self.document_type_dict[document_type]
+ else:
+ skip_formats = [s.strip() for s in skip_formats.split(',')]
+ def useFormat(format):
+ if use_formats:
+ return format in use_formats
+ if skip_formats:
+ return format not in skip_formats
+ return True
+ self.document_type_dict[document_type] = [format for format in self.document_type_dict[document_type] if useFormat(format)]
def getAllowedTo(self, mimetype=None, document_type=None, extension=None):
"""
Modified: erp5/trunk/utils/oood/oood.conf
URL: http://svn.erp5.org/erp5/trunk/utils/oood/oood.conf?rev=14497&r1=14496&r2=14497&view=diff
==============================================================================
--- erp5/trunk/utils/oood/oood.conf (original)
+++ erp5/trunk/utils/oood/oood.conf Tue May 15 16:30:35 2007
@@ -74,3 +74,33 @@
# ID of the virtual display where OOo instances are launched
virtual_display_id = 99
+###################################################################
+# Formats
+###################################################################
+# Here you can configure which file formats should be included on the
+# "target format item list" and which should be skipped
+# by either specifying formats to use, or formats to skip
+# default is using all formats defined in mimemapper
+# Format list should be given as comma-separated list of extensions
+# (as defined in mimemapper)
+# example:
+# [Text]
+# use_formats = odt, doc, rtf, html-writer, pdf
+# [Spreadsheet]
+# skip_formats = slk, pxl, 3_0.sdc.vor
+
+[Text]
+#use_formats = All
+#skip_formats = None
+
+[Spreadsheet]
+#use_formats = All
+#skip_formats = None
+
+[Presentation]
+#use_formats = All
+#skip_formats = None
+
+[Drawing]
+#use_formats = All
+#skip_formats = None
More information about the Erp5-report
mailing list