Don't pass request into run_process_media
People(tm) want to start run_process_media from the CLI and might not have a request object handy. So pass in the feed_url into run_process_media rather than the request object and allow the feed url to be empty (resulting in no PuSH notification at all then). Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
2cfffd5ed8
commit
c7b3d070b6
@ -86,7 +86,10 @@ def post_entry(request):
|
|||||||
#
|
#
|
||||||
# (... don't change entry after this point to avoid race
|
# (... don't change entry after this point to avoid race
|
||||||
# conditions with changes to the document via processing code)
|
# conditions with changes to the document via processing code)
|
||||||
run_process_media(entry, request)
|
feed_url = request.urlgen(
|
||||||
|
'mediagoblin.user_pages.atom_feed',
|
||||||
|
qualified=True, user=request.user.username)
|
||||||
|
run_process_media(entry, feed_url)
|
||||||
|
|
||||||
return json_response(get_entry_serializable(entry, request.urlgen))
|
return json_response(get_entry_serializable(entry, request.urlgen))
|
||||||
|
|
||||||
|
@ -94,7 +94,8 @@ class ProcessMedia(task.Task):
|
|||||||
entry.save()
|
entry.save()
|
||||||
|
|
||||||
# Notify the PuSH servers as async task
|
# Notify the PuSH servers as async task
|
||||||
handle_push_urls.subtask().delay(feed_url)
|
if mgg.app_config["push_urls"] and feed_url:
|
||||||
|
handle_push_urls.subtask().delay(feed_url)
|
||||||
|
|
||||||
json_processing_callback(entry)
|
json_processing_callback(entry)
|
||||||
except BaseProcessingFail as exc:
|
except BaseProcessingFail as exc:
|
||||||
|
@ -54,10 +54,14 @@ def prepare_queue_task(app, entry, filename):
|
|||||||
return queue_file
|
return queue_file
|
||||||
|
|
||||||
|
|
||||||
def run_process_media(entry, request):
|
def run_process_media(entry, feed_url=None):
|
||||||
feed_url = request.urlgen(
|
"""Process the media asynchronously
|
||||||
'mediagoblin.user_pages.atom_feed',
|
|
||||||
qualified=True, user=request.user.username)
|
:param entry: MediaEntry() instance to be processed.
|
||||||
|
:param feed_url: A string indicating the feed_url that the PuSH servers
|
||||||
|
should be notified of. This will be sth like: `request.urlgen(
|
||||||
|
'mediagoblin.user_pages.atom_feed',qualified=True,
|
||||||
|
user=request.user.username)`"""
|
||||||
try:
|
try:
|
||||||
process_media.apply_async(
|
process_media.apply_async(
|
||||||
[entry.id, feed_url], {},
|
[entry.id, feed_url], {},
|
||||||
|
@ -89,7 +89,10 @@ def submit_start(request):
|
|||||||
#
|
#
|
||||||
# (... don't change entry after this point to avoid race
|
# (... don't change entry after this point to avoid race
|
||||||
# conditions with changes to the document via processing code)
|
# conditions with changes to the document via processing code)
|
||||||
run_process_media(entry, request)
|
feed_url = request.urlgen(
|
||||||
|
'mediagoblin.user_pages.atom_feed',
|
||||||
|
qualified=True, user=request.user.username)
|
||||||
|
run_process_media(entry, feed_url)
|
||||||
add_message(request, SUCCESS, _('Woohoo! Submitted!'))
|
add_message(request, SUCCESS, _('Woohoo! Submitted!'))
|
||||||
|
|
||||||
return redirect(request, "mediagoblin.user_pages.user_home",
|
return redirect(request, "mediagoblin.user_pages.user_home",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user