Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move service redirects out into their own module to reduce clutter.
- Loading branch information
Showing
5 changed files
with
70 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
""" Handle general redirect stuff. | ||
This module name gets a 'zz_' tacked on the front so that it comes last. | ||
We need to catch /updates/{id}/request and /updates/{id}/edit first and those | ||
get defined in the other service modules. | ||
""" | ||
|
||
from cornice import Service | ||
|
||
from pyramid.httpexceptions import HTTPFound | ||
|
||
import bodhi.security | ||
|
||
from bodhi.services.comments import comments | ||
from bodhi.services.overrides import overrides | ||
from bodhi.services.updates import updates | ||
from bodhi.services.user import users | ||
|
||
|
||
def redirect_maker(target): | ||
def redirector(request): | ||
url = request.route_url('updates_rss') | ||
if request.query_string: | ||
url = url + '?' + request.query_string | ||
raise HTTPFound(url) | ||
return redirector | ||
|
||
|
||
@comments.get(accept=('application/atom+xml',)) | ||
def comments_rss_redirect(request): | ||
return redirect_maker('comments_rss')(request) | ||
|
||
|
||
@overrides.get(accept=('application/atom+xml',)) | ||
def overrides_rss_redirect(request): | ||
return redirect_maker('overrides_rss')(request) | ||
|
||
|
||
@updates.get(accept=('application/atom+xml',)) | ||
def updates_rss_redirect(request): | ||
return redirect_maker('updates_rss')(request) | ||
|
||
|
||
@users.get(accept=('application/atom+xml',)) | ||
def users_rss_redirect(request): | ||
return redirect_maker('users_rss')(request) | ||
|
||
|
||
zz_bodhi1_update_redirect = Service( | ||
name='bodhi1_update_redirect', path='/updates/{id}/{title}', | ||
description='Redirect to old updates/ALIAS/TITLE urls', | ||
cors_origins=bodhi.security.cors_origins_rw) | ||
|
||
@zz_bodhi1_update_redirect.get() | ||
def zz_get_bodhi1_update_redirect(request): | ||
return HTTPFound("/updates/{0}".format(request.matchdict['id'])) |