Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lettuce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
lettuce
Commits
dac57b6e
Commit
dac57b6e
authored
Jul 17, 2013
by
mike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move lettuce.django import into enable() method of plugin
parent
3891f7ea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
39 deletions
+39
-39
lettuce/plugins/smtp_mail_queue.py
+39
-39
No files found.
lettuce/plugins/smtp_mail_queue.py
View file @
dac57b6e
...
@@ -9,7 +9,6 @@ from smtpd import SMTPServer
...
@@ -9,7 +9,6 @@ from smtpd import SMTPServer
from
django.core.mail
import
EmailMessage
,
EmailMultiAlternatives
from
django.core.mail
import
EmailMessage
,
EmailMultiAlternatives
from
lettuce
import
after
,
before
from
lettuce
import
after
,
before
from
lettuce.django
import
mail
def
_parse_header
(
val
):
def
_parse_header
(
val
):
...
@@ -55,6 +54,8 @@ def _convert_to_django_msg(msg):
...
@@ -55,6 +54,8 @@ def _convert_to_django_msg(msg):
def
enable
():
def
enable
():
from
django.conf
import
settings
from
django.conf
import
settings
from
lettuce.django
import
mail
smtp_queue_server
=
None
smtp_queue_server
=
None
@before.each_scenario
@before.each_scenario
...
@@ -70,41 +71,40 @@ def enable():
...
@@ -70,41 +71,40 @@ def enable():
global
smtp_queue_server
global
smtp_queue_server
smtp_queue_server
.
stop
()
smtp_queue_server
.
stop
()
class
QueueSMTPServer
(
SMTPServer
,
threading
.
Thread
):
class
QueueSMTPServer
(
SMTPServer
,
threading
.
Thread
):
"""
"""
Asyncore SMTP server wrapped into a thread.
Asyncore SMTP server wrapped into a thread.
It pushes incoming email messages into lettuce email queue.
It pushes incoming email messages into lettuce email queue.
Based on DummyFTPServer from:
Based on DummyFTPServer from:
http://svn.python.org/view/python/branches/py3k/Lib/test/test_ftplib.py?revision=86061&view=markup
http://svn.python.org/view/python/branches/py3k/Lib/test/test_ftplib.py?revision=86061&view=markup
"""
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
threading
.
Thread
.
__init__
(
self
)
threading
.
Thread
.
__init__
(
self
)
SMTPServer
.
__init__
(
self
,
*
args
,
**
kwargs
)
SMTPServer
.
__init__
(
self
,
*
args
,
**
kwargs
)
self
.
active_lock
=
threading
.
Lock
()
self
.
active_lock
=
threading
.
Lock
()
self
.
active
=
False
self
.
active
=
False
self
.
daemon
=
True
self
.
daemon
=
True
def
process_message
(
self
,
peer
,
mailfrom
,
rcpttos
,
data
):
def
process_message
(
self
,
peer
,
mailfrom
,
rcpttos
,
data
):
msg
=
message_from_string
(
data
)
msg
=
message_from_string
(
data
)
django_msg
=
_convert_to_django_msg
(
msg
)
django_msg
=
_convert_to_django_msg
(
msg
)
mail
.
queue
.
put
(
django_msg
)
mail
.
queue
.
put
(
django_msg
)
def
start
(
self
):
def
start
(
self
):
assert
not
self
.
active
assert
not
self
.
active
self
.
__flag
=
threading
.
Event
()
self
.
__flag
=
threading
.
Event
()
threading
.
Thread
.
start
(
self
)
threading
.
Thread
.
start
(
self
)
def
run
(
self
):
def
run
(
self
):
self
.
active
=
True
self
.
active
=
True
self
.
__flag
.
set
()
self
.
__flag
.
set
()
while
self
.
active
and
asyncore
.
socket_map
:
while
self
.
active
and
asyncore
.
socket_map
:
self
.
active_lock
.
acquire
()
self
.
active_lock
.
acquire
()
asyncore
.
loop
(
timeout
=
0.1
,
count
=
1
)
asyncore
.
loop
(
timeout
=
0.1
,
count
=
1
)
self
.
active_lock
.
release
()
self
.
active_lock
.
release
()
asyncore
.
close_all
()
asyncore
.
close_all
()
def
stop
(
self
):
def
stop
(
self
):
assert
self
.
active
assert
self
.
active
self
.
active
=
False
self
.
active
=
False
self
.
join
()
self
.
join
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment