Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lettuce and django email #215

Closed
oinopion opened this issue Jan 6, 2012 · 8 comments
Closed

Lettuce and django email #215

oinopion opened this issue Jan 6, 2012 · 8 comments
Assignees

Comments

@oinopion
Copy link

oinopion commented Jan 6, 2012

I've just spent 2 hours debugging why I can't access django.core.mail.outbox.
This led me to discovery of ThreadedServer which is not threaded at all, rather it's sub-process.
Because sub-process has separate memory, outbox on the parent process stays empty forever.
I'm not sure what's the best way to fix this, but some documentation should help.

Since this is one of Google's top post on using lettuce with Django, I think there should be some more clarification .

@oinopion
Copy link
Author

oinopion commented Jan 6, 2012

There is very little room to make changes to email handling, since harvest command calls setup_test_environment that overwrites settings.EMAIL_BACKEND. I ended up with overwriting this setting in before.handle_request hook (since this is only hook running in server process) and using file-based email backend.

I think exposing EMAIL_BACKEND override would help tremendously.

@suvash
Copy link

suvash commented Jan 11, 2012

I spent 6 hours today on this very same problem ! I agree with the above statement.

@suvash
Copy link

suvash commented Jan 11, 2012

btw, @oinopion could you share how you overrode the setting ?

@oinopion
Copy link
Author

Very simply:

# in terrain.py
from lettuce import before, after, world
from django.conf import settings

@before.handle_request
    def override_mail_settings(httpd, server):
        settings.EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'

@suvash
Copy link

suvash commented Jan 12, 2012

Ah nice, thanks a lot. I tried the same, and it took me a while to figure out that i didn't work when I put the terrain file in the features folder, but it did work in the root folder.

Thanks again.

@gabrielfalcao
Copy link
Owner

I'm about to release lettuce 0.2.0 with a new website and documentation which will have a full-featured django tutorial.
I'll make sure to point out this edge case in the tutorial.

Thanks

@kjin-
Copy link

kjin- commented Sep 18, 2012

@oinopion thanks for highlighting this here. I spent 3 hours on figuring this out before I saw this.

@ghost ghost assigned gabrielfalcao Sep 20, 2012
@gabrielfalcao
Copy link
Owner

closed by #313

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants