Merge branch 'mediagoblin-upstream' into feature544_basic_license_data
This commit is contained in:
commit
291e24f397
@ -50,6 +50,8 @@ allow_attachments = boolean(default=False)
|
|||||||
# Cookie stuff
|
# Cookie stuff
|
||||||
csrf_cookie_name = string(default='mediagoblin_csrftoken')
|
csrf_cookie_name = string(default='mediagoblin_csrftoken')
|
||||||
|
|
||||||
|
# Push stuff
|
||||||
|
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")
|
||||||
|
28
mediagoblin/db/sql/fake.py
Normal file
28
mediagoblin/db/sql/fake.py
Normal 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)
|
@ -20,6 +20,10 @@ from os.path import splitext
|
|||||||
from cgi import FieldStorage
|
from cgi import FieldStorage
|
||||||
|
|
||||||
from celery import registry
|
from celery import registry
|
||||||
|
import urllib,urllib2
|
||||||
|
import logging
|
||||||
|
|
||||||
|
_log = logging.getLogger(__name__)
|
||||||
|
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
|
||||||
@ -129,6 +133,30 @@ def submit_start(request):
|
|||||||
# re-raise the exception
|
# re-raise the exception
|
||||||
raise
|
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!'))
|
add_message(request, SUCCESS, _('Woohoo! Submitted!'))
|
||||||
|
|
||||||
return redirect(request, "mediagoblin.user_pages.user_home",
|
return redirect(request, "mediagoblin.user_pages.user_home",
|
||||||
|
@ -228,16 +228,25 @@ def atom_feed(request):
|
|||||||
"""
|
"""
|
||||||
ATOM feed id is a tag URI (see http://en.wikipedia.org/wiki/Tag_URI)
|
ATOM feed id is a tag URI (see http://en.wikipedia.org/wiki/Tag_URI)
|
||||||
"""
|
"""
|
||||||
|
atomlinks = [{
|
||||||
|
'href': request.urlgen(
|
||||||
|
'mediagoblin.user_pages.user_home',
|
||||||
|
qualified=True,user=request.matchdict['user']),
|
||||||
|
'rel': 'alternate',
|
||||||
|
'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(
|
feed = AtomFeed(
|
||||||
"MediaGoblin: Feed for user '%s'" % request.matchdict['user'],
|
"MediaGoblin: Feed for user '%s'" % request.matchdict['user'],
|
||||||
feed_url=request.url,
|
feed_url=request.url,
|
||||||
id='tag:'+request.host+',2011:gallery.user-'+request.matchdict['user'],
|
id='tag:'+request.host+',2011:gallery.user-'+request.matchdict['user'],
|
||||||
links=[{
|
links=atomlinks)
|
||||||
'href': request.urlgen(
|
|
||||||
'mediagoblin.user_pages.user_home',
|
|
||||||
qualified=True,user=request.matchdict['user']),
|
|
||||||
'rel': 'alternate',
|
|
||||||
'type': 'text/html'}])
|
|
||||||
|
|
||||||
for entry in cursor:
|
for entry in cursor:
|
||||||
feed.add(entry.get('title'),
|
feed.add(entry.get('title'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user