title: Pyramid: generate json views from list
body: <p>How to generate <code>json</code> views from a list of strings with Pyramid?</p>
  
  <p>With the following attempt only the view of the last element of the list is generated; <code>jkl_json</code> in this case,  the others produce <code>404 Not Found</code>.</p>
  
  <pre><code>names = ['abc', 'def', 'ghi', 'jkl']
  for nm in names:
      @view_config(route_name='{}_json'.format(nm),
                   renderer='json',)
      def names_json(request):
          nm_cls = globals()[nm.title()]
          ...
  </code></pre>
  
  <p>This does actually work with html views; but not with json views.</p>