SuffixedResource(Resource): def content_types_provided(self, request, response): return ( ('application/json', self.to_json), ) def format_suffix_accepted(self, request, response): return ( ("json", "application/json"), ) def allowed_methods(self, request, response): return ('GET', ) def get_urls(self): regexp = getattr(self, "url_regexp") or r'^$' # Add format suffix formats = dict(self.format_suffix_accepted(None, None)) regexp = regexp[:-1] + r'(.%s)?' % '|'.join(formats.keys()) + regexp[-1] # -- urlpatterns = patterns('', url(regexp, self, name="%s_index" % self.__class__.__name__), ) return urlpatterns