mikeboers / Flask-Images

On-demand resizing of images for Flask applications.
https://mikeboers.github.io/Flask-Images/
BSD 3-Clause "New" or "Revised" License
81 stars 43 forks source link

Not working on Cron job #41

Closed erwinyusrizal closed 7 years ago

erwinyusrizal commented 7 years ago

Hi @mikeboers thanks for this awesome extension

I have an issue to use flask-images with Flask-Apscheduler, I have a cron job to send email which is has images in my email template that needs to be sent along with email, all the app context is working good but the flask-images throws error

`File "../email/myemail.html", line 32, in top-level template code

File "../python2.7/site-packages/flask/helpers.py", line 332, in url_for return appctx.app.handle_url_build_error(error, endpoint, values) File "../python2.7/site-packages/flask/app.py", line 1800, in handle_url_build_error rv = handler(error, endpoint, values) File "../python2.7/site-packages/flask_images/core.py", line 124, in build_error_handler return self.build_url(filename, mode=mode, **values) File "../python2.7/site-packages/flask_images/core.py", line 206, in build_url scheme or request.scheme, `

RuntimeError: Working outside of request context.

but still doesnt work, any idea?

erwinyusrizal commented 7 years ago

Ok it's working now, my mistake, before I was used app_context thats why it doesnt work, but it's working with

with scheduler.app.test_request_context():

Cheers,