From dbfb8c00f1118c3645e18b65eca2461e736799e2 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 13 Aug 2009 19:53:56 -0700 Subject: fix for http://trac.turbogears.org/ticket/2351 TG would throw an exception if a client supplied an Accept header that didn't match the content_type of the expose decorator. --- quoins/controllers.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/quoins/controllers.py b/quoins/controllers.py index ac3cef7..6aac7a2 100644 --- a/quoins/controllers.py +++ b/quoins/controllers.py @@ -217,6 +217,9 @@ class Feed(TGController): @expose(content_type='application/atom+xml') def atom1_0(self, **kw): + # fix for http://trac.turbogears.org/ticket/2351 + if request.headers.get('Accept', '') == 'text/html': + abort(500, "This page returns application/atom+xml, please set your Accept header appropriately.") info = self.get_feed_data(**kw) feed = Atom1Feed( title=info['title'], @@ -236,6 +239,9 @@ class Feed(TGController): @expose(content_type='application/rss+xml') def rss2_0(self, **kw): + # fix for http://trac.turbogears.org/ticket/2351 + if request.headers.get('Accept', '') == 'text/html': + abort(500, "This page returns application/rss+xml, please set your Accept header appropriately.") info = self.get_feed_data(**kw) feed = Rss201rev2Feed( title=info['title'], @@ -261,6 +267,9 @@ class Pingback(TGController): @expose(content_type='text/xml') def index(self): + # fix for http://trac.turbogears.org/ticket/2351 + if request.headers.get('Accept', '') == 'text/html': + abort(500, "This page returns text/xml, please set your Accept header appropriately.") try: params, method = xmlrpclib.loads(request.body) log.debug('Pingback method: %s' % method) @@ -501,7 +510,6 @@ Comment: def post(self, id): post = DBSession.query(Post).get(id) if not post: abort(404) - print pylons.request.headers pylons.response.headers['X-Pingback']=self.absolute_url('/pingback/') return dict(quoins = self, blog = post.blog, -- cgit v1.2.3