I have just released Flask-Mail 0.5. This is basically a refactoring release, with a couple of small external changes: 1. The setting MAIL_FAIL_SILENTLY. If False then an error will be raised if attempting to connect to an unavailable mail server. This is True by default. 2. The ability to limit the number of emails sent in a single connection through the max_emails argument/DEFAULT_MAX_EMAILS setting. Details can be found here :http://packages.python.org/Flask-Mail/. I have decided to keep Lamson for the forseeable future, as it handles most of the low-level encoding and other functionality and it would not make sense to rewrite this functionality. The documentation has been updated with workarounds for Windows users. I would be grateful for Windows users to provide more detailed instructions or corrections.
Hi Dan, I tried using Flask-Mail in a flask module and recieved an error message. --- from flask import Module from flaskext.mail import Mail admin = Module(__name__) mail = Mail(admin) --- is there anyway to setup a Mail instance in flask.Module? Thanks EJ Lee 2010/8/7 Dan Jacob <danjac354@gmail.com>: > I have just released Flask-Mail 0.5. This is basically a refactoring > release, with a couple of small external changes: > > 1. The setting MAIL_FAIL_SILENTLY. If False then an error will be > raised if attempting to connect to an unavailable mail server. This is > True by default. > > 2. The ability to limit the number of emails sent in a single > connection through the max_emails argument/DEFAULT_MAX_EMAILS setting. > > Details can be found here :http://packages.python.org/Flask-Mail/. > > I have decided to keep Lamson for the forseeable future, as it handles > most of the low-level encoding and other functionality and it would > not make sense to rewrite this functionality. The documentation has > been updated with workarounds for Windows users. I would be grateful > for Windows users to provide more detailed instructions or > corrections. >
No, it's enabled through an app, not a module. Why would you need to initialize it that way ? On 25 August 2010 14:43, Eunjin Lee <hdformat@gmail.com> wrote: > Hi Dan, > > I tried using Flask-Mail in a flask module and recieved an error message. > --- > from flask import Module > from flaskext.mail import Mail > > admin = Module(__name__) > mail = Mail(admin) > --- > is there anyway to setup a Mail instance in flask.Module? > > Thanks > EJ Lee > > > 2010/8/7 Dan Jacob <danjac354@gmail.com>: >> I have just released Flask-Mail 0.5. This is basically a refactoring >> release, with a couple of small external changes: >> >> 1. The setting MAIL_FAIL_SILENTLY. If False then an error will be >> raised if attempting to connect to an unavailable mail server. This is >> True by default. >> >> 2. The ability to limit the number of emails sent in a single >> connection through the max_emails argument/DEFAULT_MAX_EMAILS setting. >> >> Details can be found here :http://packages.python.org/Flask-Mail/. >> >> I have decided to keep Lamson for the forseeable future, as it handles >> most of the low-level encoding and other functionality and it would >> not make sense to rewrite this functionality. The documentation has >> been updated with workarounds for Windows users. I would be grateful >> for Windows users to provide more detailed instructions or >> corrections. >> >
pardon me, I'm a novice in python and programming also English, my app structure is like below. it's based on the 'Patterns for Flask - Larger Applications' -- /yourapplication __init__.py /apps /frontend __init__.py views.py /static style.css /templates index.html about.html ... /admin __init__.py views.py /static style.css /templates list_items.html show_item.html ... --- when Mail instance is created in /youapplication/__init__.py, how I use it in /youraplication/apps/admin/views.py? 2010/8/25 Dan Jacob <danjac354@gmail.com>: > No, it's enabled through an app, not a module. Why would you need to > initialize it that way ? > > On 25 August 2010 14:43, Eunjin Lee <hdformat@gmail.com> wrote: >> Hi Dan, >> >> I tried using Flask-Mail in a flask module and recieved an error message. >> --- >> from flask import Module >> from flaskext.mail import Mail >> >> admin = Module(__name__) >> mail = Mail(admin) >> --- >> is there anyway to setup a Mail instance in flask.Module? >> >> Thanks >> EJ Lee >> >> >> 2010/8/7 Dan Jacob <danjac354@gmail.com>: >>> I have just released Flask-Mail 0.5. This is basically a refactoring >>> release, with a couple of small external changes: >>> >>> 1. The setting MAIL_FAIL_SILENTLY. If False then an error will be >>> raised if attempting to connect to an unavailable mail server. This is >>> True by default. >>> >>> 2. The ability to limit the number of emails sent in a single >>> connection through the max_emails argument/DEFAULT_MAX_EMAILS setting. >>> >>> Details can be found here :http://packages.python.org/Flask-Mail/. >>> >>> I have decided to keep Lamson for the forseeable future, as it handles >>> most of the low-level encoding and other functionality and it would >>> not make sense to rewrite this functionality. The documentation has >>> been updated with workarounds for Windows users. I would be grateful >>> for Windows users to provide more detailed instructions or >>> corrections. >>> >> >
Don't create the instance in __init__.py.
Have a separate module (e.g. extensions.py) and initialise it there:
mail = Mail()
You can then initialise it in __init__.py:
from myapp.extensions import mail
app = Flask(__name__)
mail.init_app(app)
and you can also use it in your views:
from myapp.extensions import mail
@mymodule.route("/")
def myview():
mail.send_message(...)
On 25 August 2010 16:06, Eunjin Lee <hdformat@gmail.com> wrote:
> pardon me, I'm a novice in python and programming also English,
>
> my app structure is like below. it's based on the 'Patterns for Flask
> - Larger Applications'
> --
> /yourapplication
> __init__.py
> /apps
> /frontend
> __init__.py
> views.py
> /static
> style.css
> /templates
> index.html
> about.html
> ...
> /admin
> __init__.py
> views.py
> /static
> style.css
> /templates
> list_items.html
> show_item.html
> ...
> ---
> when Mail instance is created in /youapplication/__init__.py,
>
> how I use it in /youraplication/apps/admin/views.py?
>
>
> 2010/8/25 Dan Jacob <danjac354@gmail.com>:
>> No, it's enabled through an app, not a module. Why would you need to
>> initialize it that way ?
>>
>> On 25 August 2010 14:43, Eunjin Lee <hdformat@gmail.com> wrote:
>>> Hi Dan,
>>>
>>> I tried using Flask-Mail in a flask module and recieved an error message.
>>> ---
>>> from flask import Module
>>> from flaskext.mail import Mail
>>>
>>> admin = Module(__name__)
>>> mail = Mail(admin)
>>> ---
>>> is there anyway to setup a Mail instance in flask.Module?
>>>
>>> Thanks
>>> EJ Lee
>>>
>>>
>>> 2010/8/7 Dan Jacob <danjac354@gmail.com>:
>>>> I have just released Flask-Mail 0.5. This is basically a refactoring
>>>> release, with a couple of small external changes:
>>>>
>>>> 1. The setting MAIL_FAIL_SILENTLY. If False then an error will be
>>>> raised if attempting to connect to an unavailable mail server. This is
>>>> True by default.
>>>>
>>>> 2. The ability to limit the number of emails sent in a single
>>>> connection through the max_emails argument/DEFAULT_MAX_EMAILS setting.
>>>>
>>>> Details can be found here :http://packages.python.org/Flask-Mail/.
>>>>
>>>> I have decided to keep Lamson for the forseeable future, as it handles
>>>> most of the low-level encoding and other functionality and it would
>>>> not make sense to rewrite this functionality. The documentation has
>>>> been updated with workarounds for Windows users. I would be grateful
>>>> for Windows users to provide more detailed instructions or
>>>> corrections.
>>>>
>>>
>>
>
It works!!! Thank you, Dan. :) Regards, Ej Lee 2010/8/26 Dan Jacob <danjac354@gmail.com>: > Don't create the instance in __init__.py. > > Have a separate module (e.g. extensions.py) and initialise it there: > > mail = Mail() > > You can then initialise it in __init__.py: > > from myapp.extensions import mail > > app = Flask(__name__) > > mail.init_app(app) > > and you can also use it in your views: > > from myapp.extensions import mail > > @mymodule.route("/") > def myview(): > mail.send_message(...) > > > On 25 August 2010 16:06, Eunjin Lee <hdformat@gmail.com> wrote: >> pardon me, I'm a novice in python and programming also English, >> >> my app structure is like below. it's based on the 'Patterns for Flask >> - Larger Applications' >> -- >> /yourapplication >> __init__.py >> /apps >> /frontend >> __init__.py >> views.py >> /static >> style.css >> /templates >> index.html >> about.html >> ... >> /admin >> __init__.py >> views.py >> /static >> style.css >> /templates >> list_items.html >> show_item.html >> ... >> --- >> when Mail instance is created in /youapplication/__init__.py, >> >> how I use it in /youraplication/apps/admin/views.py? >> >> >> 2010/8/25 Dan Jacob <danjac354@gmail.com>: >>> No, it's enabled through an app, not a module. Why would you need to >>> initialize it that way ? >>> >>> On 25 August 2010 14:43, Eunjin Lee <hdformat@gmail.com> wrote: >>>> Hi Dan, >>>> >>>> I tried using Flask-Mail in a flask module and recieved an error message. >>>> --- >>>> from flask import Module >>>> from flaskext.mail import Mail >>>> >>>> admin = Module(__name__) >>>> mail = Mail(admin) >>>> --- >>>> is there anyway to setup a Mail instance in flask.Module? >>>> >>>> Thanks >>>> EJ Lee >>>> >>>> >>>> 2010/8/7 Dan Jacob <danjac354@gmail.com>: >>>>> I have just released Flask-Mail 0.5. This is basically a refactoring >>>>> release, with a couple of small external changes: >>>>> >>>>> 1. The setting MAIL_FAIL_SILENTLY. If False then an error will be >>>>> raised if attempting to connect to an unavailable mail server. This is >>>>> True by default. >>>>> >>>>> 2. The ability to limit the number of emails sent in a single >>>>> connection through the max_emails argument/DEFAULT_MAX_EMAILS setting. >>>>> >>>>> Details can be found here :http://packages.python.org/Flask-Mail/. >>>>> >>>>> I have decided to keep Lamson for the forseeable future, as it handles >>>>> most of the low-level encoding and other functionality and it would >>>>> not make sense to rewrite this functionality. The documentation has >>>>> been updated with workarounds for Windows users. I would be grateful >>>>> for Windows users to provide more detailed instructions or >>>>> corrections. >>>>> >>>> >>> >> >
I am confused about the multiple apps. Do each of them define their own Flask() instance, or are they each modules that contain views packages? This part of the doc needs lots of love. -- Thadeus On Wed, Aug 25, 2010 at 10:17 AM, Dan Jacob <danjac354@gmail.com> wrote: > Don't create the instance in __init__.py. > > Have a separate module (e.g. extensions.py) and initialise it there: > > mail = Mail() > > You can then initialise it in __init__.py: > > from myapp.extensions import mail > > app = Flask(__name__) > > mail.init_app(app) > > and you can also use it in your views: > > from myapp.extensions import mail > > @mymodule.route("/") > def myview(): > mail.send_message(...) > > > On 25 August 2010 16:06, Eunjin Lee <hdformat@gmail.com> wrote: >> pardon me, I'm a novice in python and programming also English, >> >> my app structure is like below. it's based on the 'Patterns for Flask >> - Larger Applications' >> -- >> /yourapplication >> __init__.py >> /apps >> /frontend >> __init__.py >> views.py >> /static >> style.css >> /templates >> index.html >> about.html >> ... >> /admin >> __init__.py >> views.py >> /static >> style.css >> /templates >> list_items.html >> show_item.html >> ... >> --- >> when Mail instance is created in /youapplication/__init__.py, >> >> how I use it in /youraplication/apps/admin/views.py? >> >> >> 2010/8/25 Dan Jacob <danjac354@gmail.com>: >>> No, it's enabled through an app, not a module. Why would you need to >>> initialize it that way ? >>> >>> On 25 August 2010 14:43, Eunjin Lee <hdformat@gmail.com> wrote: >>>> Hi Dan, >>>> >>>> I tried using Flask-Mail in a flask module and recieved an error message. >>>> --- >>>> from flask import Module >>>> from flaskext.mail import Mail >>>> >>>> admin = Module(__name__) >>>> mail = Mail(admin) >>>> --- >>>> is there anyway to setup a Mail instance in flask.Module? >>>> >>>> Thanks >>>> EJ Lee >>>> >>>> >>>> 2010/8/7 Dan Jacob <danjac354@gmail.com>: >>>>> I have just released Flask-Mail 0.5. This is basically a refactoring >>>>> release, with a couple of small external changes: >>>>> >>>>> 1. The setting MAIL_FAIL_SILENTLY. If False then an error will be >>>>> raised if attempting to connect to an unavailable mail server. This is >>>>> True by default. >>>>> >>>>> 2. The ability to limit the number of emails sent in a single >>>>> connection through the max_emails argument/DEFAULT_MAX_EMAILS setting. >>>>> >>>>> Details can be found here :http://packages.python.org/Flask-Mail/. >>>>> >>>>> I have decided to keep Lamson for the forseeable future, as it handles >>>>> most of the low-level encoding and other functionality and it would >>>>> not make sense to rewrite this functionality. The documentation has >>>>> been updated with workarounds for Windows users. I would be grateful >>>>> for Windows users to provide more detailed instructions or >>>>> corrections. >>>>> >>>> >>> >> >
> I am confused about the multiple apps. Do each of them define their > own Flask() instance, or are they each modules that contain views > packages? This part of the doc needs lots of love. http://flask.pocoo.org/docs/api/#flask.Module
That does not answer the question. Examine the comments alongside the filetree. Does all of this mean you end up with two Flask() instances, or one instance that can pull the module depending on some sort of domain argument? 'Patterns for Flask - Larger Applications' -- /yourapplication __init__.py # What goes here? app = Flask(), ??? /apps /frontend __init__.py # What about here, is this the module definition, or is the the app = Flask()???? views.py # Are these modules, or just functions? /static style.css /templates index.html about.html ... /admin __init__.py # Same here, is this another app = Flask() instance, or a admin module? views.py # can sub modules be here ??? /static style.css /templates list_items.html show_item.html ... --- -- Thadeus On Wed, Aug 25, 2010 at 10:53 AM, Dag Odenhall <dag.odenhall@gmail.com> wrote: >> I am confused about the multiple apps. Do each of them define their >> own Flask() instance, or are they each modules that contain views >> packages? This part of the doc needs lots of love. > > http://flask.pocoo.org/docs/api/#flask.Module > >
Where is multiple apps mentioned ? On 25 August 2010 16:23, Thadeus Burgess <thadeusb@thadeusb.com> wrote: > I am confused about the multiple apps. Do each of them define their > own Flask() instance, or are they each modules that contain views > packages? This part of the doc needs lots of love. > > -- > Thadeus > > > > > > On Wed, Aug 25, 2010 at 10:17 AM, Dan Jacob <danjac354@gmail.com> wrote: >> Don't create the instance in __init__.py. >> >> Have a separate module (e.g. extensions.py) and initialise it there: >> >> mail = Mail() >> >> You can then initialise it in __init__.py: >> >> from myapp.extensions import mail >> >> app = Flask(__name__) >> >> mail.init_app(app) >> >> and you can also use it in your views: >> >> from myapp.extensions import mail >> >> @mymodule.route("/") >> def myview(): >> mail.send_message(...) >> >> >> On 25 August 2010 16:06, Eunjin Lee <hdformat@gmail.com> wrote: >>> pardon me, I'm a novice in python and programming also English, >>> >>> my app structure is like below. it's based on the 'Patterns for Flask >>> - Larger Applications' >>> -- >>> /yourapplication >>> __init__.py >>> /apps >>> /frontend >>> __init__.py >>> views.py >>> /static >>> style.css >>> /templates >>> index.html >>> about.html >>> ... >>> /admin >>> __init__.py >>> views.py >>> /static >>> style.css >>> /templates >>> list_items.html >>> show_item.html >>> ... >>> --- >>> when Mail instance is created in /youapplication/__init__.py, >>> >>> how I use it in /youraplication/apps/admin/views.py? >>> >>> >>> 2010/8/25 Dan Jacob <danjac354@gmail.com>: >>>> No, it's enabled through an app, not a module. Why would you need to >>>> initialize it that way ? >>>> >>>> On 25 August 2010 14:43, Eunjin Lee <hdformat@gmail.com> wrote: >>>>> Hi Dan, >>>>> >>>>> I tried using Flask-Mail in a flask module and recieved an error message. >>>>> --- >>>>> from flask import Module >>>>> from flaskext.mail import Mail >>>>> >>>>> admin = Module(__name__) >>>>> mail = Mail(admin) >>>>> --- >>>>> is there anyway to setup a Mail instance in flask.Module? >>>>> >>>>> Thanks >>>>> EJ Lee >>>>> >>>>> >>>>> 2010/8/7 Dan Jacob <danjac354@gmail.com>: >>>>>> I have just released Flask-Mail 0.5. This is basically a refactoring >>>>>> release, with a couple of small external changes: >>>>>> >>>>>> 1. The setting MAIL_FAIL_SILENTLY. If False then an error will be >>>>>> raised if attempting to connect to an unavailable mail server. This is >>>>>> True by default. >>>>>> >>>>>> 2. The ability to limit the number of emails sent in a single >>>>>> connection through the max_emails argument/DEFAULT_MAX_EMAILS setting. >>>>>> >>>>>> Details can be found here :http://packages.python.org/Flask-Mail/. >>>>>> >>>>>> I have decided to keep Lamson for the forseeable future, as it handles >>>>>> most of the low-level encoding and other functionality and it would >>>>>> not make sense to rewrite this functionality. The documentation has >>>>>> been updated with workarounds for Windows users. I would be grateful >>>>>> for Windows users to provide more detailed instructions or >>>>>> corrections. >>>>>> >>>>> >>>> >>> >> >