@@ -0,0 +1,1356 @@
+from StringIO import StringIO%0Aimport greplin.scales%0Aimport greplin.scales.formats%0Aimport greplin.scales.util%0A%0A%0Adef scales_stats(request):%0A    parts = request.matchdict.get('prefix')%0A    path = '/'.join(parts)%0A    stats = greplin.scales.util.lookup(greplin.scales.getStats(), parts)%0A%0A    output = StringIO()%0A    outputFormat = request.params.get('format', 'html')%0A    query = request.params.get('query', None)%0A    if outputFormat == 'json':%0A        request.response.content_type = 'application/json'%0A        greplin.scales.formats.jsonFormat(output, stats, query)%0A    elif outputFormat == 'prettyjson':%0A        request.response.content_type = 'application/json'%0A        greplin.scales.formats.jsonFormat(output, stats, query, pretty=True)%0A    else:%0A        request.response.content_type = 'text/html'%0A        # XXX Dear pyramid.renderers.string_renderer_factory,%0A        # you can't be serious%0A        request.response.default_content_type = 'not-text/html'%0A        output.write('%3Chtml%3E')%0A        greplin.scales.formats.htmlHeader(output, '/' + path, __name__, query)%0A        greplin.scales.formats.htmlFormat(output, tuple(parts), stats, query)%0A        output.write('%3C/html%3E')%0A%0A    return output.getvalue()%0A%0A%0Adef includeme(config):%0A    config.add_route('scales', '/scales/*prefix')%0A    config.add_view(scales_stats, route_name='scales', renderer='string')%0A

Paste in implementation from our blog post http://blog.gocept.com/2013/08/20/viewing-scales-metrics-from-pyramid/