From bb025ebda14297b721f8816d13980a477f62bca6 Mon Sep 17 00:00:00 2001 From: Michele Azzolari Date: Thu, 12 Jan 2012 11:05:05 +0100 Subject: [PATCH] As per spec, we permit to have more then 1 hub --- mediagoblin/config_spec.ini | 2 +- mediagoblin/submit/views.py | 12 +++++++----- mediagoblin/user_pages/views.py | 9 +++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/mediagoblin/config_spec.ini b/mediagoblin/config_spec.ini index b8e7b193..dc286a27 100644 --- a/mediagoblin/config_spec.ini +++ b/mediagoblin/config_spec.ini @@ -51,7 +51,7 @@ allow_attachments = boolean(default=False) csrf_cookie_name = string(default='mediagoblin_csrftoken') # Push stuff -push_url = string(default='') +push_urls = string_list(default=list()) [storage:publicstore] storage_class = string(default="mediagoblin.storage.filestorage:BasicFileStorage") diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py index de280422..65243ca1 100644 --- a/mediagoblin/submit/views.py +++ b/mediagoblin/submit/views.py @@ -126,18 +126,20 @@ def submit_start(request): # re-raise the exception raise - if mg_globals.app_config["push_url"]: + if mg_globals.app_config["push_urls"]: feed_url=request.urlgen( 'mediagoblin.user_pages.atom_feed', qualified=True,user=request.user.username) hubparameters = { 'hub.mode': 'publish', 'hub.url': feed_url} - huburl = mg_globals.app_config["push_url"] hubdata = urllib.urlencode(hubparameters) - hubheaders = {"Content-type": "application/x-www-form-urlencoded"} - hubrequest = urllib2.Request(huburl, hubdata,hubheaders) - hubresponse = urllib2.urlopen(hubrequest) + hubheaders = { + "Content-type": "application/x-www-form-urlencoded", + "Connection": "close"} + for huburl in mg_globals.app_config["push_urls"]: + hubrequest = urllib2.Request(huburl, hubdata,hubheaders) + hubresponse = urllib2.urlopen(hubrequest) add_message(request, SUCCESS, _('Woohoo! Submitted!')) diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index 2d4eac69..29360e23 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -235,10 +235,11 @@ def atom_feed(request): 'rel': 'alternate', 'type': 'text/html' }]; - if mg_globals.app_config["push_url"]: - atomlinks.append({ - 'rel': 'hub', - 'href': mg_globals.app_config["push_url"]}) + if mg_globals.app_config["push_urls"]: + for push_url in mg_globals.app_config["push_urls"]: + atomlinks.append({ + 'rel': 'hub', + 'href': push_url}) feed = AtomFeed( "MediaGoblin: Feed for user '%s'" % request.matchdict['user'], -- 2.25.1