Opened 7 years ago
Last modified 7 years ago
#13252 new defect
Xmail filter did not execute
Reported by: | ntmlod | Owned by: | Franz |
---|---|---|---|
Priority: | normal | Component: | MailPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 1.0 |
Description
On our Trac 1.0.1, I ran into a first issue during installation
2017-07-31 21:21:06,196 Trac[loader] ERROR: Skipping "xmail = xmail": Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/trac/loader.py", line 68, in _load_eggs entry.load(require=True) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load entry = __import__(self.module_name, globals(),globals(), ['__name__']) File "build/bdist.linux-x86_64/egg/xmail/__init__.py", line 2, in <module> File "build/bdist.linux-x86_64/egg/xmail/XMailEMailModule.py", line 22, in <module> ImportError: cannot import name Locale
I followed the fix suggested by rjollos on comment:2:ticket:12580
-
xmail/XMailEMailModule.py
19 19 from trac.notification import NotifyEmail 20 20 from trac.util import translation 21 21 from trac.util.datefmt import format_datetime 22 from trac.util.translation import Locale,activate, domain_functions22 from trac.util.translation import activate, domain_functions 23 23 from trac.web.api import ITemplateStreamFilter 24 from trac.prefs.web_ui import Locale 24 25 from xmail.XMailFilterObject import FilterObject 25 26 from trac.core import Component, implements 26 27
Then everything seemed to go well, for testing I configured a first filter, checked the tickets list, activated it and set the execution for few minutes later but nothing happened even in the log. On Xmail page, lastsuccessexe
is !void.
The date format used by Xmail MM/DD/YY hh:mm:ss
is not the one configured for Trac (ISO8601
) but I tested I can use both. Also I found that our DB is not at the same time zone as Trac but if it was an issue we would have been in trouble for a long time.
Attachments (0)
Change History (4)
comment:1 Changed 7 years ago by
comment:2 follow-up: 4 Changed 7 years ago by
It would be simple to use req.locale
rather than Locale.negotiate
(untested).
However, it should not store to _locale_string
property of Component
instance. Only single instance of Component
is created for all threads.
-
mailplugin/trunk/xmail/XMailEMailModule.py
diff --git a/mailplugin/trunk/xmail/XMailEMailModule.py b/mailplugin/trunk/xmail/XMailEMailModule.py index 1caffe5df..bcb7281d2 100644
a b from pkg_resources import resource_filename # @UnresolvedImport 17 17 from trac.config import IntOption 18 18 from trac.loader import get_plugin_info 19 19 from trac.notification import NotifyEmail 20 from trac.util import translation21 20 from trac.util.datefmt import format_datetime 22 from trac.util.translation import Locale,activate, domain_functions21 from trac.util.translation import activate, domain_functions 23 22 from trac.web.api import ITemplateStreamFilter 24 23 from xmail.XMailFilterObject import FilterObject 25 24 from trac.core import Component, implements … … class XMailEventHandler(Component): 49 48 add_domain(self.env.path, locale_dir) 50 49 51 50 def filter_stream(self, req, method, filename, stream, data): 52 if Locale and not self._TimerIsStillAlive(): 53 # copied from main.py:310ff 54 available = [locale_id.replace('_', '-') for locale_id in 55 translation.get_available_locales()] 56 57 preferred = req.session.get('language', req.languages) 58 if not isinstance(preferred, list): 59 preferred = [preferred] 60 self._locale_string = Locale.negotiate( 61 preferred, available, sep='-') 62 self.log.debug("Negotiated locale: %s -> %s", 63 preferred, self._locale_string) 64 51 if not self._TimerIsStillAlive(): 52 self._locale_string = str(req.locale) if req.locale else 'en_US' 65 53 return stream 66 54 67 55 #=========================================================================
comment:3 Changed 7 years ago by
Other issue, db api should be used for username in the following:
xmail/XMailEMailModule.py:
242 def _get_user_data(self, username): 243 sql = ("select name, value from session_attribute where name in ('language', 'email')" 244 " and sid='%s'" % username)
xmail/XMailMainView.py:
215 sql = "select " + \ 216 get_col_list(['username', 'selectfields', 'whereclause']) 217 sql += " from " + XMAIL_TABLE.name + " where username='" + \ 218 req.authname + "' order by filtername"
comment:4 Changed 7 years ago by
Replying to Jun Omae:
It would be simple to use
req.locale
rather thanLocale.negotiate
(untested).However, it should not store to
_locale_string
property ofComponent
instance. Only single instance ofComponent
is created for all threads.
mailplugin/trunk/xmail/XMailEMailModule.py
diff --git a/mailplugin/trunk/xmail/XMailEMailModule.py b/mailplugin/trunk/xmail/XMailEMailModule.py index 1caffe5df..bcb7281d2 100644
a b from pkg_resources import resource_filename # @UnresolvedImport 17 17 from trac.config import IntOption 18 18 from trac.loader import get_plugin_info 19 19 from trac.notification import NotifyEmail 20 from trac.util import translation21 20 from trac.util.datefmt import format_datetime 22 from trac.util.translation import Locale,activate, domain_functions21 from trac.util.translation import activate, domain_functions 23 22 from trac.web.api import ITemplateStreamFilter 24 23 from xmail.XMailFilterObject import FilterObject 25 24 from trac.core import Component, implements … … class XMailEventHandler(Component): 49 48 add_domain(self.env.path, locale_dir) 50 49 51 50 def filter_stream(self, req, method, filename, stream, data): 52 if Locale and not self._TimerIsStillAlive(): 53 # copied from main.py:310ff 54 available = [locale_id.replace('_', '-') for locale_id in 55 translation.get_available_locales()] 56 57 preferred = req.session.get('language', req.languages) 58 if not isinstance(preferred, list): 59 preferred = [preferred] 60 self._locale_string = Locale.negotiate( 61 preferred, available, sep='-') 62 self.log.debug("Negotiated locale: %s -> %s", 63 preferred, self._locale_string) 64 51 if not self._TimerIsStillAlive(): 52 self._locale_string = str(req.locale) if req.locale else 'en_US' 65 53 return stream 66 54 67 55 #=========================================================================
I applied your patch but now the Xmail page loads indefinitely... Nothing in the log
It must not import
Locale
symbol from any module undertrac.*
.