librelist archives

« back to archive

ANN: Flask-Mail 0.4 pre-release

ANN: Flask-Mail 0.4 pre-release

From:
Dan Jacob
Date:
2010-08-05 @ 17:00
I will soon be releasing Flask-Mail 0.4 for acceptance testing.

This new version deprecates the old way of doing unit tests.
Previously in testing mode messages where added to the g object as
g.outbox. This was unsatisfactory for a number of reasons. Fortunately
the new signalling support in Flask makes it unnecessary.

Instead a signal is now used, which is fired whenever an email is
dispatched. This can be captured using a record_messages() method:

    mail = Mail(app)

    with mail.record_messages() as outbox:
        mail.send_message(....)
        assert len(outbox) == 1

In addition the signals support can of course be used for your own
purposes, for example logging.

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Thadeus Burgess
Date:
2010-08-06 @ 04:45
Flask-Mail does not work on windows since it depends on lamson, for
which seem to be no documents on installing in windows.... pip install
fails with ImportError: No module named resource.

It might be worth noting this in the documentation, or providing a
workaround (without using cygwin).

--
Thadeus





On Thu, Aug 5, 2010 at 12:00 PM, Dan Jacob <danjac354@gmail.com> wrote:
> I will soon be releasing Flask-Mail 0.4 for acceptance testing.
>
> This new version deprecates the old way of doing unit tests.
> Previously in testing mode messages where added to the g object as
> g.outbox. This was unsatisfactory for a number of reasons. Fortunately
> the new signalling support in Flask makes it unnecessary.
>
> Instead a signal is now used, which is fired whenever an email is
> dispatched. This can be captured using a record_messages() method:
>
>    mail = Mail(app)
>
>    with mail.record_messages() as outbox:
>        mail.send_message(....)
>        assert len(outbox) == 1
>
> In addition the signals support can of course be used for your own
> purposes, for example logging.
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Thadeus Burgess
Date:
2010-08-06 @ 04:52
The problem is that lamson depends on python-daemon, which
incidentally only works on linux.

--
Thadeus





On Thu, Aug 5, 2010 at 11:45 PM, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
> Flask-Mail does not work on windows since it depends on lamson, for
> which seem to be no documents on installing in windows.... pip install
> fails with ImportError: No module named resource.
>
> It might be worth noting this in the documentation, or providing a
> workaround (without using cygwin).
>
> --
> Thadeus
>
>
>
>
>
> On Thu, Aug 5, 2010 at 12:00 PM, Dan Jacob <danjac354@gmail.com> wrote:
>> I will soon be releasing Flask-Mail 0.4 for acceptance testing.
>>
>> This new version deprecates the old way of doing unit tests.
>> Previously in testing mode messages where added to the g object as
>> g.outbox. This was unsatisfactory for a number of reasons. Fortunately
>> the new signalling support in Flask makes it unnecessary.
>>
>> Instead a signal is now used, which is fired whenever an email is
>> dispatched. This can be captured using a record_messages() method:
>>
>>    mail = Mail(app)
>>
>>    with mail.record_messages() as outbox:
>>        mail.send_message(....)
>>        assert len(outbox) == 1
>>
>> In addition the signals support can of course be used for your own
>> purposes, for example logging.
>>
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Dan Jacob
Date:
2010-08-06 @ 07:34
Thanks for pointing out this issue.

The question is really whether to remove the Lamson dependency (using
plain smtplib or another Windows-friendly library) or to notify
Windows users that Flask-Mail will not work on their platform. Pity,
as Lamson does a lot of what Flask-Mail needs to do and I'd like to
avoid NIH.

I'm tempted to the former, but this will require a fair amount of
rewriting, so I'll add the notification in the docs for the time being
and plan a move away from Lamson in 0.5.

Unless of course Windows users can provide a valid workaround.

On 6 August 2010 05:52, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
> The problem is that lamson depends on python-daemon, which
> incidentally only works on linux.
>
> --
> Thadeus
>
>
>
>
>
> On Thu, Aug 5, 2010 at 11:45 PM, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
>> Flask-Mail does not work on windows since it depends on lamson, for
>> which seem to be no documents on installing in windows.... pip install
>> fails with ImportError: No module named resource.
>>
>> It might be worth noting this in the documentation, or providing a
>> workaround (without using cygwin).
>>
>> --
>> Thadeus
>>
>>
>>
>>
>>
>> On Thu, Aug 5, 2010 at 12:00 PM, Dan Jacob <danjac354@gmail.com> wrote:
>>> I will soon be releasing Flask-Mail 0.4 for acceptance testing.
>>>
>>> This new version deprecates the old way of doing unit tests.
>>> Previously in testing mode messages where added to the g object as
>>> g.outbox. This was unsatisfactory for a number of reasons. Fortunately
>>> the new signalling support in Flask makes it unnecessary.
>>>
>>> Instead a signal is now used, which is fired whenever an email is
>>> dispatched. This can be captured using a record_messages() method:
>>>
>>>    mail = Mail(app)
>>>
>>>    with mail.record_messages() as outbox:
>>>        mail.send_message(....)
>>>        assert len(outbox) == 1
>>>
>>> In addition the signals support can of course be used for your own
>>> purposes, for example logging.
>>>
>>
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Dag Odenhall
Date:
2010-08-06 @ 13:27
> Thanks for pointing out this issue.
> 
> The question is really whether to remove the Lamson dependency (using
> plain smtplib or another Windows-friendly library) or to notify
> Windows users that Flask-Mail will not work on their platform. Pity,
> as Lamson does a lot of what Flask-Mail needs to do and I'd like to
> avoid NIH.
> 
> I'm tempted to the former, but this will require a fair amount of
> rewriting, so I'll add the notification in the docs for the time being
> and plan a move away from Lamson in 0.5.
> 
> Unless of course Windows users can provide a valid workaround.

How about communicating with upstream about Windows support?

Maybe they could drop the dependency on python-daemon (suggesting that
it can be installed if desired) or python-daemon could be made to work
on Windows (maybe by a noop).

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Dan Jacob
Date:
2010-08-06 @ 13:33
That's a good point. Most likely python-daemon is needed to run the
Lamson mail server (I assume so; this is a guess) and it's unlikely to
be run in a Windows environment.

As Flask-Mail only uses the mail sending functionality python-daemon
is not needed, and as JimG pointed out, you can install with
--no-dependencies. I've amended the docs to say as much although more
detailed instructions from a Windows user would be better.

On 6 August 2010 14:27, Dag Odenhall <dag.odenhall@gmail.com> wrote:
>> Thanks for pointing out this issue.
>>
>> The question is really whether to remove the Lamson dependency (using
>> plain smtplib or another Windows-friendly library) or to notify
>> Windows users that Flask-Mail will not work on their platform. Pity,
>> as Lamson does a lot of what Flask-Mail needs to do and I'd like to
>> avoid NIH.
>>
>> I'm tempted to the former, but this will require a fair amount of
>> rewriting, so I'll add the notification in the docs for the time being
>> and plan a move away from Lamson in 0.5.
>>
>> Unless of course Windows users can provide a valid workaround.
>
> How about communicating with upstream about Windows support?
>
> Maybe they could drop the dependency on python-daemon (suggesting that
> it can be installed if desired) or python-daemon could be made to work
> on Windows (maybe by a noop).
>
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Thadeus Burgess
Date:
2010-08-06 @ 16:37
Would it be worth supporting both lamson and smtplib in the case
lamson does not exist?

--
Thadeus





On Fri, Aug 6, 2010 at 8:33 AM, Dan Jacob <danjac354@gmail.com> wrote:
> s Flask-Mail only uses the mail sending functionality python-daemon
> is not needed, and as JimG pointed out, you can install with
> --no-dependencies. I've amen

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Dan Jacob
Date:
2010-08-06 @ 16:41
What would be the point ? Once you have recoded Flask-Mail to use
smtplib instead of Lamson, there is no point in using Lamson, as
Lamson is used for all the low-level smtp calls.

On 6 August 2010 17:37, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
> Would it be worth supporting both lamson and smtplib in the case
> lamson does not exist?
>
> --
> Thadeus
>
>
>
>
>
> On Fri, Aug 6, 2010 at 8:33 AM, Dan Jacob <danjac354@gmail.com> wrote:
>> s Flask-Mail only uses the mail sending functionality python-daemon
>> is not needed, and as JimG pointed out, you can install with
>> --no-dependencies. I've amen
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Thadeus Burgess
Date:
2010-08-06 @ 16:46
As long as --no-dependencies work with lamson on the windows side as
the workaround, and I can still test my flask applications, I could
live with that.

--
Thadeus





On Fri, Aug 6, 2010 at 11:41 AM, Dan Jacob <danjac354@gmail.com> wrote:
> What would be the point ? Once you have recoded Flask-Mail to use
> smtplib instead of Lamson, there is no point in using Lamson, as
> Lamson is used for all the low-level smtp calls.
>
> On 6 August 2010 17:37, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
>> Would it be worth supporting both lamson and smtplib in the case
>> lamson does not exist?
>>
>> --
>> Thadeus
>>
>>
>>
>>
>>
>> On Fri, Aug 6, 2010 at 8:33 AM, Dan Jacob <danjac354@gmail.com> wrote:
>>> s Flask-Mail only uses the mail sending functionality python-daemon
>>> is not needed, and as JimG pointed out, you can install with
>>> --no-dependencies. I've amen
>>
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Thadeus Burgess
Date:
2010-08-06 @ 17:44
I would like to at least have a feature added for 0.4

Add a reconnect_after option for the connect(with_many=True). My SMTP
server only allows 500 messages at a time, and then it will close the
connection. So if I need to send 600, the script crashes. This would
basically just keep track of how many messages it is sending
(internally), and then reconnect to the SMTP server if it has filled
its qouta. You shouldn't have to specify reconnect after though.

I just sent you a pull request on bitbucket, what do you think?

--
Thadeus





On Fri, Aug 6, 2010 at 11:46 AM, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
> As long as --no-dependencies work with lamson on the windows side as
> the workaround, and I can still test my flask applications, I could
> live with that.
>
> --
> Thadeus
>
>
>
>
>
> On Fri, Aug 6, 2010 at 11:41 AM, Dan Jacob <danjac354@gmail.com> wrote:
>> What would be the point ? Once you have recoded Flask-Mail to use
>> smtplib instead of Lamson, there is no point in using Lamson, as
>> Lamson is used for all the low-level smtp calls.
>>
>> On 6 August 2010 17:37, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
>>> Would it be worth supporting both lamson and smtplib in the case
>>> lamson does not exist?
>>>
>>> --
>>> Thadeus
>>>
>>>
>>>
>>>
>>>
>>> On Fri, Aug 6, 2010 at 8:33 AM, Dan Jacob <danjac354@gmail.com> wrote:
>>>> s Flask-Mail only uses the mail sending functionality python-daemon
>>>> is not needed, and as JimG pointed out, you can install with
>>>> --no-dependencies. I've amen
>>>
>>
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Dan Jacob
Date:
2010-08-06 @ 17:50
I can add this functionality certainly.

There are two ways this should be configured in two ways:

1. A max_emails argument to connect()
2. A config setting DEFAULT_MAX_EMAILS

If 1) is not specified then 2) is assumed (by default no limit).

On 6 August 2010 18:44, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
> I would like to at least have a feature added for 0.4
>
> Add a reconnect_after option for the connect(with_many=True). My SMTP
> server only allows 500 messages at a time, and then it will close the
> connection. So if I need to send 600, the script crashes. This would
> basically just keep track of how many messages it is sending
> (internally), and then reconnect to the SMTP server if it has filled
> its qouta. You shouldn't have to specify reconnect after though.
>
> I just sent you a pull request on bitbucket, what do you think?
>
> --
> Thadeus
>
>
>
>
>
> On Fri, Aug 6, 2010 at 11:46 AM, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
>> As long as --no-dependencies work with lamson on the windows side as
>> the workaround, and I can still test my flask applications, I could
>> live with that.
>>
>> --
>> Thadeus
>>
>>
>>
>>
>>
>> On Fri, Aug 6, 2010 at 11:41 AM, Dan Jacob <danjac354@gmail.com> wrote:
>>> What would be the point ? Once you have recoded Flask-Mail to use
>>> smtplib instead of Lamson, there is no point in using Lamson, as
>>> Lamson is used for all the low-level smtp calls.
>>>
>>> On 6 August 2010 17:37, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
>>>> Would it be worth supporting both lamson and smtplib in the case
>>>> lamson does not exist?
>>>>
>>>> --
>>>> Thadeus
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Fri, Aug 6, 2010 at 8:33 AM, Dan Jacob <danjac354@gmail.com> wrote:
>>>>> s Flask-Mail only uses the mail sending functionality python-daemon
>>>>> is not needed, and as JimG pointed out, you can install with
>>>>> --no-dependencies. I've amen
>>>>
>>>
>>
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Thadeus Burgess
Date:
2010-08-06 @ 17:54
I like.

--
Thadeus





On Fri, Aug 6, 2010 at 12:50 PM, Dan Jacob <danjac354@gmail.com> wrote:
> I can add this functionality certainly.
>
> There are two ways this should be configured in two ways:
>
> 1. A max_emails argument to connect()
> 2. A config setting DEFAULT_MAX_EMAILS
>
> If 1) is not specified then 2) is assumed (by default no limit).
>
> On 6 August 2010 18:44, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
>> I would like to at least have a feature added for 0.4
>>
>> Add a reconnect_after option for the connect(with_many=True). My SMTP
>> server only allows 500 messages at a time, and then it will close the
>> connection. So if I need to send 600, the script crashes. This would
>> basically just keep track of how many messages it is sending
>> (internally), and then reconnect to the SMTP server if it has filled
>> its qouta. You shouldn't have to specify reconnect after though.
>>
>> I just sent you a pull request on bitbucket, what do you think?
>>
>> --
>> Thadeus
>>
>>
>>
>>
>>
>> On Fri, Aug 6, 2010 at 11:46 AM, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
>>> As long as --no-dependencies work with lamson on the windows side as
>>> the workaround, and I can still test my flask applications, I could
>>> live with that.
>>>
>>> --
>>> Thadeus
>>>
>>>
>>>
>>>
>>>
>>> On Fri, Aug 6, 2010 at 11:41 AM, Dan Jacob <danjac354@gmail.com> wrote:
>>>> What would be the point ? Once you have recoded Flask-Mail to use
>>>> smtplib instead of Lamson, there is no point in using Lamson, as
>>>> Lamson is used for all the low-level smtp calls.
>>>>
>>>> On 6 August 2010 17:37, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
>>>>> Would it be worth supporting both lamson and smtplib in the case
>>>>> lamson does not exist?
>>>>>
>>>>> --
>>>>> Thadeus
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Aug 6, 2010 at 8:33 AM, Dan Jacob <danjac354@gmail.com> wrote:
>>>>>> s Flask-Mail only uses the mail sending functionality python-daemon
>>>>>> is not needed, and as JimG pointed out, you can install with
>>>>>> --no-dependencies. I've amen
>>>>>
>>>>
>>>
>>
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Dan Jacob
Date:
2010-08-06 @ 21:37
I've created a new "smtp" branch for Flask-Mail:

http://bitbucket.org/danjac/flask-mail

This branch drops the Lamson dependency, using just Python stdlib
email packages (although I have borrowed heavily from the Lamson
source code).

It also implements the max emails functionality as discussed in this thread.

This branch is experimental, and requires more tests (and testing).

I'm not sure at this point whether to drop Lamson, as its low-level
functionality is useful and I don't like reinventing the wheel for the
sake of Windows (sorry), especially if a workaround is available.
However the general refactoring that has been done on this branch will
be added into the 0.5 release.


On 6 August 2010 18:54, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
> I like.
>
> --
> Thadeus
>
>
>
>
>
> On Fri, Aug 6, 2010 at 12:50 PM, Dan Jacob <danjac354@gmail.com> wrote:
>> I can add this functionality certainly.
>>
>> There are two ways this should be configured in two ways:
>>
>> 1. A max_emails argument to connect()
>> 2. A config setting DEFAULT_MAX_EMAILS
>>
>> If 1) is not specified then 2) is assumed (by default no limit).
>>
>> On 6 August 2010 18:44, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
>>> I would like to at least have a feature added for 0.4
>>>
>>> Add a reconnect_after option for the connect(with_many=True). My SMTP
>>> server only allows 500 messages at a time, and then it will close the
>>> connection. So if I need to send 600, the script crashes. This would
>>> basically just keep track of how many messages it is sending
>>> (internally), and then reconnect to the SMTP server if it has filled
>>> its qouta. You shouldn't have to specify reconnect after though.
>>>
>>> I just sent you a pull request on bitbucket, what do you think?
>>>
>>> --
>>> Thadeus
>>>
>>>
>>>
>>>
>>>
>>> On Fri, Aug 6, 2010 at 11:46 AM, Thadeus Burgess 
<thadeusb@thadeusb.com> wrote:
>>>> As long as --no-dependencies work with lamson on the windows side as
>>>> the workaround, and I can still test my flask applications, I could
>>>> live with that.
>>>>
>>>> --
>>>> Thadeus
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Fri, Aug 6, 2010 at 11:41 AM, Dan Jacob <danjac354@gmail.com> wrote:
>>>>> What would be the point ? Once you have recoded Flask-Mail to use
>>>>> smtplib instead of Lamson, there is no point in using Lamson, as
>>>>> Lamson is used for all the low-level smtp calls.
>>>>>
>>>>> On 6 August 2010 17:37, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
>>>>>> Would it be worth supporting both lamson and smtplib in the case
>>>>>> lamson does not exist?
>>>>>>
>>>>>> --
>>>>>> Thadeus
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Aug 6, 2010 at 8:33 AM, Dan Jacob <danjac354@gmail.com> wrote:
>>>>>>> s Flask-Mail only uses the mail sending functionality python-daemon
>>>>>>> is not needed, and as JimG pointed out, you can install with
>>>>>>> --no-dependencies. I've amen
>>>>>>
>>>>>
>>>>
>>>
>>
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Armin Ronacher
Date:
2010-08-06 @ 21:48
Hi,

On 8/6/10 11:37 PM, Dan Jacob wrote:
> This branch drops the Lamson dependency, using just Python stdlib
> email packages (although I have borrowed heavily from the Lamson
> source code).
To be honest: I don't like the idea.  That means the Flask extension 
suddenly has so much code in there that it makes sense to take the 
extension and to fork it for another framework.

Lamson works perfectly fine on Windows as utility library and if it's 
too hard for people to setup, then the correct solution would be a patch 
for Lamson that supports automatic falling back on Windows.

Alternatively one could split lamson into two packages: LamsonServer and 
LamsonUtils.


Regards,
Armin

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Dan Jacob
Date:
2010-08-06 @ 21:55
On 6 August 2010 22:48, Armin Ronacher <armin.ronacher@active-4.com> wrote:
> Hi,
>
> On 8/6/10 11:37 PM, Dan Jacob wrote:
>> This branch drops the Lamson dependency, using just Python stdlib
>> email packages (although I have borrowed heavily from the Lamson
>> source code).
> To be honest: I don't like the idea.  That means the Flask extension
> suddenly has so much code in there that it makes sense to take the
> extension and to fork it for another framework.

I'm not too keen either. I wanted to see how much work was involved,
and Lamson does a lot of useful (and more to the point, secure) low
level smtp stuff that's frankly tiresome to rewrite.

There's some useful refactoring that's come out of the work though, so
it wasn't a complete waste of time.

>
> Lamson works perfectly fine on Windows as utility library and if it's
> too hard for people to setup, then the correct solution would be a patch
> for Lamson that supports automatic falling back on Windows.
>
> Alternatively one could split lamson into two packages: LamsonServer and
> LamsonUtils.
>

I'll put a request up on the Lamson mailing list.

Ultimately Flask extensions should, if possible, reuse existing
packages and avoid NIH. In some cases that's not possible (there is no
package or existing packages don't measure up) but that's not the case
here.

I would like feedback from Windows users on installation however so
that the docs can be amended accordingly.

>
> Regards,
> Armin
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
LeafStorm
Date:
2010-08-06 @ 22:38
On 8/6/10, Dan Jacob <danjac354@gmail.com> wrote:
> On 6 August 2010 22:48, Armin Ronacher <armin.ronacher@active-4.com> wrote:
>> Hi,
>>
>> On 8/6/10 11:37 PM, Dan Jacob wrote:
>>> This branch drops the Lamson dependency, using just Python stdlib
>>> email packages (although I have borrowed heavily from the Lamson
>>> source code).
>> To be honest: I don't like the idea.  That means the Flask extension
>> suddenly has so much code in there that it makes sense to take the
>> extension and to fork it for another framework.
>
> I'm not too keen either. I wanted to see how much work was involved,
> and Lamson does a lot of useful (and more to the point, secure) low
> level smtp stuff that's frankly tiresome to rewrite.
>
> There's some useful refactoring that's come out of the work though, so
> it wasn't a complete waste of time.
>
>>
>> Lamson works perfectly fine on Windows as utility library and if it's
>> too hard for people to setup, then the correct solution would be a patch
>> for Lamson that supports automatic falling back on Windows.
>>
>> Alternatively one could split lamson into two packages: LamsonServer and
>> LamsonUtils.
>>
>
> I'll put a request up on the Lamson mailing list.
>
> Ultimately Flask extensions should, if possible, reuse existing
> packages and avoid NIH. In some cases that's not possible (there is no
> package or existing packages don't measure up) but that's not the case
> here.
>
> I would like feedback from Windows users on installation however so
> that the docs can be amended accordingly.
>
>>
>> Regards,
>> Armin
>>
>

I'm actually working on a mail-sending library called Cartero to solve
this particular niche. (One major advantage it has over Lamson for
this use case is pluggable backends. In addition to the traditional
SMTP, it will also [eventually] support using AppEngine's mail API,
dropping mail directly in a Maildir/mbox/other kind of mailbox, or
punting it somewhere else using XML-RPC.)

The source isn't on Bitbucket yet (right now I just have utility code
and the NullSender), but if Dan's interested we could work on
developing this together and Flask-Mail could use it instead of
reinventing the wheel. (Everyone else's framework could use it too.)

-- Matthew "LeafStorm" Frazier

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Dan Jacob
Date:
2010-08-06 @ 22:47
Pluggable backends would be nice, especially for something like the GAE API.

I've done a fair bit of refactoring, so most of the action is now
handled by a Connection object that does the actual smpt connect/send.
In theory that could be pluggable, something like this:

from flaskext.mail import Mail, GAEConnection

mail = Mail(app, connection_class=GAEConnection)

The bulk of the Lamson stuff is encoding the message, attachments etc,
so any backend would have to handle that as well.

On 6 August 2010 23:38, LeafStorm <leafstormrush@gmail.com> wrote:
> On 8/6/10, Dan Jacob <danjac354@gmail.com> wrote:
>> On 6 August 2010 22:48, Armin Ronacher <armin.ronacher@active-4.com> wrote:
>>> Hi,
>>>
>>> On 8/6/10 11:37 PM, Dan Jacob wrote:
>>>> This branch drops the Lamson dependency, using just Python stdlib
>>>> email packages (although I have borrowed heavily from the Lamson
>>>> source code).
>>> To be honest: I don't like the idea.  That means the Flask extension
>>> suddenly has so much code in there that it makes sense to take the
>>> extension and to fork it for another framework.
>>
>> I'm not too keen either. I wanted to see how much work was involved,
>> and Lamson does a lot of useful (and more to the point, secure) low
>> level smtp stuff that's frankly tiresome to rewrite.
>>
>> There's some useful refactoring that's come out of the work though, so
>> it wasn't a complete waste of time.
>>
>>>
>>> Lamson works perfectly fine on Windows as utility library and if it's
>>> too hard for people to setup, then the correct solution would be a patch
>>> for Lamson that supports automatic falling back on Windows.
>>>
>>> Alternatively one could split lamson into two packages: LamsonServer and
>>> LamsonUtils.
>>>
>>
>> I'll put a request up on the Lamson mailing list.
>>
>> Ultimately Flask extensions should, if possible, reuse existing
>> packages and avoid NIH. In some cases that's not possible (there is no
>> package or existing packages don't measure up) but that's not the case
>> here.
>>
>> I would like feedback from Windows users on installation however so
>> that the docs can be amended accordingly.
>>
>>>
>>> Regards,
>>> Armin
>>>
>>
>
> I'm actually working on a mail-sending library called Cartero to solve
> this particular niche. (One major advantage it has over Lamson for
> this use case is pluggable backends. In addition to the traditional
> SMTP, it will also [eventually] support using AppEngine's mail API,
> dropping mail directly in a Maildir/mbox/other kind of mailbox, or
> punting it somewhere else using XML-RPC.)
>
> The source isn't on Bitbucket yet (right now I just have utility code
> and the NullSender), but if Dan's interested we could work on
> developing this together and Flask-Mail could use it instead of
> reinventing the wheel. (Everyone else's framework could use it too.)
>
> -- Matthew "LeafStorm" Frazier
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
LeafStorm
Date:
2010-08-07 @ 20:35
On 08/06/2010 06:47 PM, Dan Jacob wrote:
> Pluggable backends would be nice, especially for something like the GAE API.
>
> I've done a fair bit of refactoring, so most of the action is now
> handled by a Connection object that does the actual smpt connect/send.
> In theory that could be pluggable, something like this:
>
> from flaskext.mail import Mail, GAEConnection
>
> mail = Mail(app, connection_class=GAEConnection)
>
> The bulk of the Lamson stuff is encoding the message, attachments etc,
> so any backend would have to handle that as well.

The problem with your approach is that it makes it difficult to change 
backends between deployments without changing the code. I was thinking 
more along the lines of having in the configuration:

     MAIL_SENDER = 'cartero.senders.smtp'
     MAIL_SENDER_OPTIONS = {'host': 'localhost', 'tls': True}
     # or, for AppEngine
     MAIL_SENDER = 'cartero.senders.appengine'
     # or during development
     MAIL_SENDER = 'cartero.senders.file'
     MAIL_SENDER_OPTIONS = {'path': '/tmp/app-emails'}

Like what Django does in django.core.mail.

Anyway, if you want to see what I have done so far with this, you can 
check http://bitbucket.org/leafstorm/cartero/. I put up a list of stuff 
I would like for it to eventually do on the project wiki.
-- 
Regards, Matthew "LeafStorm" Frazier
http://leafstorm.us/

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
JimG
Date:
2010-08-06 @ 08:11
I got it to work on Windows by (as far as I recall) installing Lamson with
the no-dependencies option then the same with Flask-Mail.

I may have needed to do this with other packages.

It did work, Thanks, Jim.

On 6 August 2010 08:34, Dan Jacob <danjac354@gmail.com> wrote:

> Thanks for pointing out this issue.
>
> The question is really whether to remove the Lamson dependency (using
> plain smtplib or another Windows-friendly library) or to notify
> Windows users that Flask-Mail will not work on their platform. Pity,
> as Lamson does a lot of what Flask-Mail needs to do and I'd like to
> avoid NIH.
>
> I'm tempted to the former, but this will require a fair amount of
> rewriting, so I'll add the notification in the docs for the time being
> and plan a move away from Lamson in 0.5.
>
> Unless of course Windows users can provide a valid workaround.
>
> On 6 August 2010 05:52, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
> > The problem is that lamson depends on python-daemon, which
> > incidentally only works on linux.
> >
> > --
> > Thadeus
> >
> >
> >
> >
> >
> > On Thu, Aug 5, 2010 at 11:45 PM, Thadeus Burgess <thadeusb@thadeusb.com>
> wrote:
> >> Flask-Mail does not work on windows since it depends on lamson, for
> >> which seem to be no documents on installing in windows.... pip install
> >> fails with ImportError: No module named resource.
> >>
> >> It might be worth noting this in the documentation, or providing a
> >> workaround (without using cygwin).
> >>
> >> --
> >> Thadeus
> >>
> >>
> >>
> >>
> >>
> >> On Thu, Aug 5, 2010 at 12:00 PM, Dan Jacob <danjac354@gmail.com> wrote:
> >>> I will soon be releasing Flask-Mail 0.4 for acceptance testing.
> >>>
> >>> This new version deprecates the old way of doing unit tests.
> >>> Previously in testing mode messages where added to the g object as
> >>> g.outbox. This was unsatisfactory for a number of reasons. Fortunately
> >>> the new signalling support in Flask makes it unnecessary.
> >>>
> >>> Instead a signal is now used, which is fired whenever an email is
> >>> dispatched. This can be captured using a record_messages() method:
> >>>
> >>>    mail = Mail(app)
> >>>
> >>>    with mail.record_messages() as outbox:
> >>>        mail.send_message(....)
> >>>        assert len(outbox) == 1
> >>>
> >>> In addition the signals support can of course be used for your own
> >>> purposes, for example logging.
> >>>
> >>
> >
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
Dan Jacob
Date:
2010-08-06 @ 08:14
Thanks for this, I'll modify the docs.

What was the exact install instructions you used ?

On 6 August 2010 09:11, JimG <j.gumbley@gmail.com> wrote:
> I got it to work on Windows by (as far as I recall) installing Lamson with
> the no-dependencies option then the same with Flask-Mail.
> I may have needed to do this with other packages.
> It did work, Thanks, Jim.
>
> On 6 August 2010 08:34, Dan Jacob <danjac354@gmail.com> wrote:
>>
>> Thanks for pointing out this issue.
>>
>> The question is really whether to remove the Lamson dependency (using
>> plain smtplib or another Windows-friendly library) or to notify
>> Windows users that Flask-Mail will not work on their platform. Pity,
>> as Lamson does a lot of what Flask-Mail needs to do and I'd like to
>> avoid NIH.
>>
>> I'm tempted to the former, but this will require a fair amount of
>> rewriting, so I'll add the notification in the docs for the time being
>> and plan a move away from Lamson in 0.5.
>>
>> Unless of course Windows users can provide a valid workaround.
>>
>> On 6 August 2010 05:52, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
>> > The problem is that lamson depends on python-daemon, which
>> > incidentally only works on linux.
>> >
>> > --
>> > Thadeus
>> >
>> >
>> >
>> >
>> >
>> > On Thu, Aug 5, 2010 at 11:45 PM, Thadeus Burgess <thadeusb@thadeusb.com>
>> > wrote:
>> >> Flask-Mail does not work on windows since it depends on lamson, for
>> >> which seem to be no documents on installing in windows.... pip install
>> >> fails with ImportError: No module named resource.
>> >>
>> >> It might be worth noting this in the documentation, or providing a
>> >> workaround (without using cygwin).
>> >>
>> >> --
>> >> Thadeus
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> On Thu, Aug 5, 2010 at 12:00 PM, Dan Jacob <danjac354@gmail.com> wrote:
>> >>> I will soon be releasing Flask-Mail 0.4 for acceptance testing.
>> >>>
>> >>> This new version deprecates the old way of doing unit tests.
>> >>> Previously in testing mode messages where added to the g object as
>> >>> g.outbox. This was unsatisfactory for a number of reasons. Fortunately
>> >>> the new signalling support in Flask makes it unnecessary.
>> >>>
>> >>> Instead a signal is now used, which is fired whenever an email is
>> >>> dispatched. This can be captured using a record_messages() method:
>> >>>
>> >>>    mail = Mail(app)
>> >>>
>> >>>    with mail.record_messages() as outbox:
>> >>>        mail.send_message(....)
>> >>>        assert len(outbox) == 1
>> >>>
>> >>> In addition the signals support can of course be used for your own
>> >>> purposes, for example logging.
>> >>>
>> >>
>> >
>
>

Re: [flask] ANN: Flask-Mail 0.4 pre-release

From:
JimG
Date:
2010-08-06 @ 08:16
I've got a virgin Windows box at work, I'll try it later and let you know.

Cheers, Jim.

On 6 August 2010 09:14, Dan Jacob <danjac354@gmail.com> wrote:

> Thanks for this, I'll modify the docs.
>
> What was the exact install instructions you used ?
>
> On 6 August 2010 09:11, JimG <j.gumbley@gmail.com> wrote:
> > I got it to work on Windows by (as far as I recall) installing Lamson
> with
> > the no-dependencies option then the same with Flask-Mail.
> > I may have needed to do this with other packages.
> > It did work, Thanks, Jim.
> >
> > On 6 August 2010 08:34, Dan Jacob <danjac354@gmail.com> wrote:
> >>
> >> Thanks for pointing out this issue.
> >>
> >> The question is really whether to remove the Lamson dependency (using
> >> plain smtplib or another Windows-friendly library) or to notify
> >> Windows users that Flask-Mail will not work on their platform. Pity,
> >> as Lamson does a lot of what Flask-Mail needs to do and I'd like to
> >> avoid NIH.
> >>
> >> I'm tempted to the former, but this will require a fair amount of
> >> rewriting, so I'll add the notification in the docs for the time being
> >> and plan a move away from Lamson in 0.5.
> >>
> >> Unless of course Windows users can provide a valid workaround.
> >>
> >> On 6 August 2010 05:52, Thadeus Burgess <thadeusb@thadeusb.com> wrote:
> >> > The problem is that lamson depends on python-daemon, which
> >> > incidentally only works on linux.
> >> >
> >> > --
> >> > Thadeus
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > On Thu, Aug 5, 2010 at 11:45 PM, Thadeus Burgess <
> thadeusb@thadeusb.com>
> >> > wrote:
> >> >> Flask-Mail does not work on windows since it depends on lamson, for
> >> >> which seem to be no documents on installing in windows.... pip
> install
> >> >> fails with ImportError: No module named resource.
> >> >>
> >> >> It might be worth noting this in the documentation, or providing a
> >> >> workaround (without using cygwin).
> >> >>
> >> >> --
> >> >> Thadeus
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> On Thu, Aug 5, 2010 at 12:00 PM, Dan Jacob <danjac354@gmail.com>
> wrote:
> >> >>> I will soon be releasing Flask-Mail 0.4 for acceptance testing.
> >> >>>
> >> >>> This new version deprecates the old way of doing unit tests.
> >> >>> Previously in testing mode messages where added to the g object as
> >> >>> g.outbox. This was unsatisfactory for a number of reasons.
> Fortunately
> >> >>> the new signalling support in Flask makes it unnecessary.
> >> >>>
> >> >>> Instead a signal is now used, which is fired whenever an email is
> >> >>> dispatched. This can be captured using a record_messages() method:
> >> >>>
> >> >>>    mail = Mail(app)
> >> >>>
> >> >>>    with mail.record_messages() as outbox:
> >> >>>        mail.send_message(....)
> >> >>>        assert len(outbox) == 1
> >> >>>
> >> >>> In addition the signals support can of course be used for your own
> >> >>> purposes, for example logging.
> >> >>>
> >> >>
> >> >
> >
> >
>