As per spec, we permit to have more then 1 hub

This commit is contained in:
Michele Azzolari 2012-01-12 11:05:05 +01:00
parent 7f251b037b
commit bb025ebda1
3 changed files with 13 additions and 10 deletions

View File

@ -51,7 +51,7 @@ allow_attachments = boolean(default=False)
csrf_cookie_name = string(default='mediagoblin_csrftoken') csrf_cookie_name = string(default='mediagoblin_csrftoken')
# Push stuff # Push stuff
push_url = string(default='') push_urls = string_list(default=list())
[storage:publicstore] [storage:publicstore]
storage_class = string(default="mediagoblin.storage.filestorage:BasicFileStorage") storage_class = string(default="mediagoblin.storage.filestorage:BasicFileStorage")

View File

@ -126,18 +126,20 @@ def submit_start(request):
# re-raise the exception # re-raise the exception
raise raise
if mg_globals.app_config["push_url"]: if mg_globals.app_config["push_urls"]:
feed_url=request.urlgen( feed_url=request.urlgen(
'mediagoblin.user_pages.atom_feed', 'mediagoblin.user_pages.atom_feed',
qualified=True,user=request.user.username) qualified=True,user=request.user.username)
hubparameters = { hubparameters = {
'hub.mode': 'publish', 'hub.mode': 'publish',
'hub.url': feed_url} 'hub.url': feed_url}
huburl = mg_globals.app_config["push_url"]
hubdata = urllib.urlencode(hubparameters) hubdata = urllib.urlencode(hubparameters)
hubheaders = {"Content-type": "application/x-www-form-urlencoded"} hubheaders = {
hubrequest = urllib2.Request(huburl, hubdata,hubheaders) "Content-type": "application/x-www-form-urlencoded",
hubresponse = urllib2.urlopen(hubrequest) "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!')) add_message(request, SUCCESS, _('Woohoo! Submitted!'))

View File

@ -235,10 +235,11 @@ def atom_feed(request):
'rel': 'alternate', 'rel': 'alternate',
'type': 'text/html' 'type': 'text/html'
}]; }];
if mg_globals.app_config["push_url"]: if mg_globals.app_config["push_urls"]:
atomlinks.append({ for push_url in mg_globals.app_config["push_urls"]:
'rel': 'hub', atomlinks.append({
'href': mg_globals.app_config["push_url"]}) 'rel': 'hub',
'href': push_url})
feed = AtomFeed( feed = AtomFeed(
"MediaGoblin: Feed for user '%s'" % request.matchdict['user'], "MediaGoblin: Feed for user '%s'" % request.matchdict['user'],