As per spec, we permit to have more then 1 hub
authorMichele Azzolari <macno@macno.org>
Thu, 12 Jan 2012 10:05:05 +0000 (11:05 +0100)
committerMichele Azzolari <macno@macno.org>
Thu, 12 Jan 2012 10:05:05 +0000 (11:05 +0100)
mediagoblin/config_spec.ini
mediagoblin/submit/views.py
mediagoblin/user_pages/views.py

index b8e7b1936ae9bbe8ee2910060535386aba1cef17..dc286a2719ead06d04fedca5686f1cf8bda58b63 100644 (file)
@@ -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")
index de2804225b4c91397f5184c0dd5281315c37fdbd..65243ca158f4c8058e4d6dd213382eb535f4dbf4 100644 (file)
@@ -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!'))
 
index 2d4eac6974fbe06a2988286b756afea247cfb59b..29360e23a8530655ee670f95693685f4677a4128 100644 (file)
@@ -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'],