parameters: (request, host, port)
return_statement: return HttpResponse(json_response, mimetype='application/json')
docstring: From GET take:  login, password : database credentials(optional, currently ignored)
                      search : text to search (optional)
                      method : re (means regular expression) or empty (means search for occurence of text) (optional)
                      if there is no search, return all databases (FIXME: handle large amount of databases)
      Return list of databases matching given criteria
docstring_summary: From GET take:  login, password : database credentials(optional, currently ignored)
                      search : text to search (optional)
                      method : re (means regular expression) or empty (means search for occurence of text) (optional)
                      if there is no search, return all databases (FIXME: handle large amount of databases)
      Return list of databases matching given criteria
docstring_tokens: From GET take : login password : database credentials ( optional currently ignored ) search : text to search ( optional ) method : re ( means regular expression ) or empty ( means search for occurence of text ) ( optional ) if there is no search return all databases ( FIXME : handle large amount of databases ) Return list of databases matching given criteria
function: def list_databases(request, host, port):
      """
      From GET take:  login, password : database credentials(optional, currently ignored)
                      search : text to search (optional)
                      method : re (means regular expression) or empty (means search for occurence of text) (optional)
                      if there is no search, return all databases (FIXME: handle large amount of databases)
      Return list of databases matching given criteria 
      """
  
      try:
          conn = pymongo.Connection(host = host, port = int(port))
          dbnames = conn.database_names()
          if request.GET:
              if 'search' in request.GET:
                  if request.GET.get('method','') =='re':
                      dbnames = [dbname for dbname in dbnames if re.match(request.GET['search'], dbname, re.IGNORECASE)]
                  else:
                      dbnames = [dbname for dbname in dbnames if request.GET['search'].lower() in dbname.lower()]
          dbnames.sort()
          json_response = json.dumps({'data':dbnames}, default=pymongo.json_util.default)
      except (Exception), e:
          json_response = (json.dumps({'error': repr(e)}))
      finally:
          conn.disconnect()
         
      return HttpResponse(json_response, mimetype='application/json')
function_tokens: def list_databases ( request , host , port ) : try : conn = pymongo . Connection ( host = host , port = int ( port ) ) dbnames = conn . database_names ( ) if request . GET : if 'search' in request . GET : if request . GET . get ( 'method' , '' ) == 're' : dbnames = [ dbname for dbname in dbnames if re . match ( request . GET [ 'search' ] , dbname , re . IGNORECASE ) ] else : dbnames = [ dbname for dbname in dbnames if request . GET [ 'search' ] . lower ( ) in dbname . lower ( ) ] dbnames . sort ( ) json_response = json . dumps ( { 'data' : dbnames } , default = pymongo . json_util . default ) except ( Exception ) , e : json_response = ( json . dumps ( { 'error' : repr ( e ) } ) ) finally : conn . disconnect ( ) return HttpResponse ( json_response , mimetype = 'application/json' )