From 75c212285a3d9571f5222828aa99a41916aa6fda Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 16 Nov 2010 16:51:44 +0200 Subject: [PATCH] email_template: cleanup the startup warning lines. Multiple coding malpractices (I can't name them errors, yet) were in those lines: - they used the netsvc.Logger() interface, which is deprecated - they wrapped too much (we're not COBOL) - they used capital letters for an object - they defined a logger object that would live throughout the module life, although it would only be useful for startup - they used the gettext function, although there is absolutely no context around to provide a language. bzr revid: p_christ@hol.gr-20101116145144-kwf7612bz0k1xzs2 --- addons/email_template/email_template.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index 5db7538d952..c20f798fbbe 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -23,10 +23,9 @@ import base64 import random import netsvc +import logging import re -LOGGER = netsvc.Logger() - TEMPLATE_ENGINES = [] from osv import osv, fields @@ -35,12 +34,9 @@ from tools.translate import _ try: from mako.template import Template as MakoTemplate TEMPLATE_ENGINES.append(('mako', 'Mako Templates')) -except: - LOGGER.notifyChannel( - _("Email Template"), - netsvc.LOG_WARNING, - _("Mako templates not installed") - ) +except ImportError: + logging.getLogger('init').warning("module email_template: Mako templates not installed") + try: from django.template import Context, Template as DjangoTemplate #Workaround for bug: @@ -49,12 +45,8 @@ try: settings.configure() #Workaround ends TEMPLATE_ENGINES.append(('django', 'Django Template')) -except: - LOGGER.notifyChannel( - _("Email Template"), - netsvc.LOG_WARNING, - _("Django templates not installed") - ) +except ImportError: + logging.getLogger('init').warning("module email_template: Django templates not installed") import tools import pooler