I have tried to use get_mailer(None) to obtain the global one, but got
"{AttributeError}'Globals' object has no attribute '_mailer' "
Then I trace the tg.app_globals object, I found it is initialized twice ,
one is in load_app() and another one is in setup_app(). Is that behavior
normal?
On Tuesday, April 14, 2015 at 12:37:13 PM UTC+8, NIWDEK wrote:
>
> Hi All,
>
> I am using tgext.mailer to send email and I found that it is testable for
> email testing by setting debugMailer to dummy
>
> Then, in the functional test case, I try to get mailer to assertion
> "mailer = get_mailer(tg.request)"
>
> However, I got an exception
>
> Traceback (most recent call last):
> File
> "/Users/xxx/.virtualenvs/yyy/lib/python3.3/site-packages/nose/case.py",
> line 198, in runTest
> self.test(*self.arg)
> File
> "/Users/xxx/Workspace/yyy/yyy/yyy/tests/functional/test_subscriber.py",
> line 28, in test_subscribe_with_email_should_send_email
> mailer = get_mailer(tg.request)
> File
> "/Users/xxx/.virtualenvs/yyy/lib/python3.3/site-packages/tgext/mailer/__init__.py",
>
> line 22, in get_mailer
> return request._mailer
> File
> "/Users/xxx/.virtualenvs/yyy/lib/python3.3/site-packages/tg/support/objectproxy.py",
>
> line 19, in __getattr__
> return getattr(self._current_obj(), attr)
> File
> "/Users/xxx/.virtualenvs/yyy/lib/python3.3/site-packages/tg/request_local.py",
>
> line 171, in _current_obj
> return getattr(context, self.name)
> File
> "/Users/xxx/.virtualenvs/yyy/lib/python3.3/site-packages/tg/support/objectproxy.py",
>
> line 19, in __getattr__
> return getattr(self._current_obj(), attr)
> File
> "/Users/xxx/.virtualenvs/yyy/lib/python3.3/site-packages/tg/support/registry.py",
>
> line 69, in _current_obj
> 'thread' % self.____name__)
> nose.proxy.TypeError: No object (name: context) has been registered for
> this thread
>
> I wonder how should I get a mailer in test case. Thanks
>
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.