title: Store large data or a service connection per Flask session
body: <p>I'm writing a small Flask application and am having it connect to Rserve using pyRserve. I want every session to initiate and then maintain its own Rserve connection. </p>
  
  <p>Something like this:</p>
  
  <pre><code>session['my_connection'] = pyRserve.connect()
  </code></pre>
  
  <p>doesn't work because the connection object is not JSON serializable. On the other hand, something like this:</p>
  
  <pre><code>flask.g.my_connection = pyRserve.connect()
  </code></pre>
  
  <p>doesn't work because it does not persist between requests. To add to the difficulty, it doesn't seem as though pyRserve provides any identifier for a connection, so I can't store a connection ID in the session and use that to retrieve the right connection before each request.</p>
  
  <p>Is there a way to accomplish having a unique connection per session?</p>