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:
@@ -54,10 +54,14 @@ def prepare_queue_task(app, entry, filename):
|
||||
return queue_file
|
||||
|
||||
|
||||
def run_process_media(entry, request):
|
||||
feed_url = request.urlgen(
|
||||
'mediagoblin.user_pages.atom_feed',
|
||||
qualified=True, user=request.user.username)
|
||||
def run_process_media(entry, feed_url=None):
|
||||
"""Process the media asynchronously
|
||||
|
||||
: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:
|
||||
process_media.apply_async(
|
||||
[entry.id, feed_url], {},
|
||||
|
||||
@@ -89,7 +89,10 @@ def submit_start(request):
|
||||
#
|
||||
# (... don't change entry after this point to avoid race
|
||||
# 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!'))
|
||||
|
||||
return redirect(request, "mediagoblin.user_pages.user_home",
|
||||
|
||||
Reference in New Issue
Block a user