title: TypeError: 'CommandCursor' object has no attribute '__getitem__'
body: <p>I am getting this TypeError when trying to access Bottle's rest API through <strong>Apache</strong> server, but it's working properly with <strong>Bottle's WSGI server</strong>.  </p>
  
  <p>Mongodb sample data:  </p>
  
  <pre><code> "_id" : ObjectId("55c4f21782f2811a08b7ddbb"),
   "TestName" : "TestName1",
   "Results" : [
       {
               "Test" : "abc",
               "Log" : "Log information"
       },
       {
               "Test" : "xyz",
               "Log" : "Log information"
       },
  ]
  </code></pre>
  
  <p><strong>I want to fetch only those records/sub document where Results.Test="abc"</strong>  </p>
  
  <p>My Bottle API code:</p>
  
  <pre><code>@route('/TestSampleApi',method='GET')
  def GetTestData():
      #request.json will have data passed in url
      pipe = [
              {"$match":{"Results": {"$elemMatch": {'Test':'abc'}}}}, 
                  { "$unwind" :"$Results"},
                  { "$match": { "Results.Test":'abc'}},
                  { "$group" : { "_id" : "$_id", "Results" : { "$addToSet" : "$Results" } }}
              ]           
              res = collection.aggregate(pipeline=pipe)
              get_record=res['result']   #getting TypeError in this line 
  
      response.set_header('Content-Type',  'application/json')
      return dumps(get_record, indent=4)
  </code></pre>
  
  <p>Above code is working properly with
  <code>curl -i GET "http://localhost:8080/TestSampleApi?Test=abc"</code><br>
  But not working with Apache:
      <code>curl -i GET "http://HOST_NAME/TestSampleApi?Test=abc"</code></p>