title: In Pyramid, how to check if view is static in NewRequest event handler?
body: <p>I have a NewRequest event handler (subscriber) in Pyramid which looks like this:</p>
  
  <pre><code>@subscriber(NewRequest)
  def new_request_subscriber(event):
      request = event.request
      print('Opening DB conn')
      // Open the DB
      request.db = my_connect_to_db()
      request.add_finished_callback(close_db_connection)
  </code></pre>
  
  <p>However, I have observed that a connection to the DB is opened even if the request goes to a static asset, which is obviously unnecessary. Is there a way, from the NewRequest handler, to check if the request is bound for a static asset? I have tried comparing the view_name to my static view's name, but apparently the view_name attribute is not available at this early stage of processing the request.</p>
  
  <p>If anyone has any interesting ideas about this, please let me know!</p>