From 99345e516b6b7ea22c67f399464cb5350b21262a Mon Sep 17 00:00:00 2001 From: Gael Pasgrimaud Date: Thu, 14 Apr 2011 17:30:20 +0200 Subject: [PATCH] add a redirect route --- pyramid_formalchemy/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyramid_formalchemy/__init__.py b/pyramid_formalchemy/__init__.py index f740597..868b477 100644 --- a/pyramid_formalchemy/__init__.py +++ b/pyramid_formalchemy/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from pyramid.httpexceptions import HTTPFound def includeme(config): """include formalchemy's zcml""" @@ -39,6 +40,11 @@ def formalchemy_admin(config, route_name, factory = type('%s_%s' % (factory.__name__, route_name), (factory,), factory_args) + def redirect(request): + return HTTPFound(location='%s/%s/' % (request.application_url, route_name)) + + config.add_route('%s_redirect' % route_name, route_name, redirect) + config.add_route(route_name, '%s/*traverse' % route_name, factory=factory)