Merge branch 'mediagoblin-upstream' into feature544_basic_license_data

This commit is contained in:
Aaron Williamson 2012-01-18 20:40:18 -05:00
commit 291e24f397
4 changed files with 73 additions and 6 deletions

View File

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

View File

@ -0,0 +1,28 @@
"""
This module contains some fake classes and functions to
calm the rest of the code base. Or provide super minimal
implementations.
Currently:
- ObjectId "class": It's a function mostly doing
int(init_arg) to convert string primary keys into
integer primary keys.
- InvalidId exception
- DESCENDING "constant"
"""
DESCENDING = object() # a unique object for this "constant"
class InvalidId(Exception):
pass
def ObjectId(value=None):
if value is None:
return None
try:
return int(value)
except ValueError:
raise InvalidId("%r is an invalid id" % value)

View File

@ -20,6 +20,10 @@ from os.path import splitext
from cgi import FieldStorage
from celery import registry
import urllib,urllib2
import logging
_log = logging.getLogger(__name__)
from werkzeug.utils import secure_filename
@ -129,6 +133,30 @@ def submit_start(request):
# re-raise the exception
raise
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}
hubdata = urllib.urlencode(hubparameters)
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)
try:
hubresponse = urllib2.urlopen(hubrequest)
except urllib2.HTTPError as exc:
# This is not a big issue, the item will be fetched
# by the PuSH server next time we hit it
_log.warning(
"push url %r gave error %r", huburl, exc.code)
except urllib2.URLError as exc:
_log.warning(
"push url %r is unreachable %r", huburl, exc.reason)
add_message(request, SUCCESS, _('Woohoo! Submitted!'))
return redirect(request, "mediagoblin.user_pages.user_home",

View File

@ -228,16 +228,25 @@ def atom_feed(request):
"""
ATOM feed id is a tag URI (see http://en.wikipedia.org/wiki/Tag_URI)
"""
feed = AtomFeed(
"MediaGoblin: Feed for user '%s'" % request.matchdict['user'],
feed_url=request.url,
id='tag:'+request.host+',2011:gallery.user-'+request.matchdict['user'],
links=[{
atomlinks = [{
'href': request.urlgen(
'mediagoblin.user_pages.user_home',
qualified=True,user=request.matchdict['user']),
'rel': 'alternate',
'type': 'text/html'}])
'type': 'text/html'
}];
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'],
feed_url=request.url,
id='tag:'+request.host+',2011:gallery.user-'+request.matchdict['user'],
links=atomlinks)
for entry in cursor:
feed.add(entry.get('title'),