Thanks for the reply, Eric. I think I figured out a solution, albeit my
question was a bit confusing. I have an e-commerce website that integrates
with a payment gateway in order to manage paid subscriptions for users.
Sometimes these subscription payments fail - either from expired cards or
insufficient funds. I wanted to create a schedule task that runs nightly
that will check the subscription statuses of each user on the payment
gateway, if a user's subscription is no longer valid due to a payment
failure I want to notify that user with an email.

The main problem I ran into is that I wanted to configure the
pyramid_mailer only once in the applications main() function and use that
instance for both the scheduled subscription status job as well as
throughout the application (ie. sending a forgotten email password).

In the end, I just pass the pyramid_mailer instance that I created in the
applications main() function to a Notifier class that handles the scheduled
job. I'm pretty sure I don't have to worry about any race conditions or
issues with thread locals since the pyramid_mailer instance is thread safe.

...a bit confusing, but thanks for your help!

-Vincent


On Sat, Mar 16, 2013 at 10:44 PM, Eric Rasmussen <ericrasmus...@gmail.com>wrote:

> I may be misunderstanding the question because I am not too familiar with
> APScheduler, but it sounds like you want to use
> mailer.send_to_queue(message) instead of mailer.send(message).
>
> As long as you're sending it to the queue for later processing there
> shouldn't be any need to have multiple Mailer instances. When you install
> pyramid_mailer you'll also get a bin/qp script to process mail in the
> queue, and you can control how and when you run that on a schedule.
>
> -Eric
>
> On Sat, Mar 16, 2013 at 1:23 AM, Vincent Catalano <
> vinc...@vincentcatalano.com> wrote:
>
>> I'm attempting to setup pyramid_mailer with a website I'm developing. The
>> current documentation (
>> http://docs.pylonsproject.org/projects/pyramid_mailer/en/latest/)
>> recommends creating a single instance of the Mailer and adding it to the
>> configuration setup. However, I want to configure numerous jobs that will
>> run separately from the Pyramid web application using something like the
>> Python APScheduler that will also send emails out to users. Instead of
>> having two separate Pyramid Mailer instances in the app, I would like to
>> abstract the email system into something more like a service . My primary
>> goal is to use the same Mailer configuration for my scheduled services as
>> my Pyramid application since this more clearly follows the principal of
>> Don't Repeat Yourself. Any ideas on how I could accomplish this?
>>
>> Thanks for your help!
>>
>> --
>> Vincent Catalano
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "pylons-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to pylons-discuss+unsubscr...@googlegroups.com.
>> To post to this group, send email to pylons-discuss@googlegroups.com.
>> Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Vincent Catalano
Software Engineer and Web Ninja,
(520).603.8944

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to