Commit 511eaf9c authored by Gabriel Monnerat's avatar Gabriel Monnerat

continuation of 43752. more refactoring

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@43776 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cfec77bb
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
# #
############################################################################## ##############################################################################
import sys
import mimetypes import mimetypes
from mimetypes import guess_all_extensions, guess_extension from mimetypes import guess_all_extensions, guess_extension
from base64 import encodestring, decodestring from base64 import encodestring, decodestring
...@@ -52,9 +51,7 @@ def getHandlerObject(source_format, destination_format, ...@@ -52,9 +51,7 @@ def getHandlerObject(source_format, destination_format,
registry_list = pattern.split() registry_list = pattern.split()
if fnmatch(source_mimetype, registry_list[0]) and \ if fnmatch(source_mimetype, registry_list[0]) and \
(fnmatch(destination_mimetype, registry_list[1]) or destination_format is None): (fnmatch(destination_mimetype, registry_list[1]) or destination_format is None):
handler_name = registry_list[2] return handler_dict[registry_list[2]]
handler = sys.modules[handler_name]
return getattr(handler, handler_dict[handler_name])
class Manager(object): class Manager(object):
......
...@@ -111,19 +111,17 @@ def application(global_config, **local_config): ...@@ -111,19 +111,17 @@ def application(global_config, **local_config):
mimemapper.loadFilterList(application_hostname, mimemapper.loadFilterList(application_hostname,
openoffice_port, **kw) openoffice_port, **kw)
openoffice.release() openoffice.release()
mimetype_registry_str = local_config.get("mimetype_registry") mimetype_registry = local_config.get("mimetype_registry", "")
kw["mimetype_registry"] = filter(None, mimetype_registry.split("\n"))
kw["handler_dict"] = {} kw["handler_dict"] = {}
handler_mapping_list = local_config.get("handler_mapping", "").split("\n") handler_mapping_list = local_config.get("handler_mapping", "").split("\n")
for line in filter(None, handler_mapping_list): for line in filter(None, handler_mapping_list):
handler_name, object_name = line.strip().split() handler_name, object_name = line.strip().split()
import_name = "cloudooo.handler.%s.handler" % handler_name import_name = "cloudooo.handler.%s.handler" % handler_name
mimetype_registry_str = mimetype_registry_str.replace(handler_name,
import_name)
if import_name not in sys.modules: if import_name not in sys.modules:
__import__(import_name) __import__(import_name)
kw["handler_dict"][import_name] = object_name handler = sys.modules[import_name]
kw["handler_dict"][handler_name] = getattr(handler, object_name)
kw["mimetype_registry"] = filter(None, mimetype_registry_str.split("\n"))
kw["env"] = environment_dict kw["env"] = environment_dict
from manager import Manager from manager import Manager
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment