code: def search(request, spec, operator='and'):
      
      api = pypi.proxy
      rv = []
      # search in proxy
      for k, v in spec.items():
          rv += api.search({k: v}, True)
  
      # search in local
      session = DBSession()
      release = Release.search(session, spec, operator)
      rv += [{'name': r.package.name,
              'version': r.version,
              'summary': r.summary,
              # hack https://mail.python.org/pipermail/catalog-sig/2012-October/004633.html
              '_pypi_ordering':'',
              } for r in release]
      return rv
docs: Search the package database using the indicated search spec.
  
      The spec may include any of the keywords described in the above list
      (except 'stable_version' and 'classifiers'),
      for example: {'description': 'spam'} will search description fields.
      Within the spec, a field's value can be a string or a list of strings
      (the values within the list are combined with an OR),
      for example: {'name': ['foo', 'bar']}.
      Valid keys for the spec dict are listed here. Invalid keys are ignored:
          name
          version
          author
          author_email
          maintainer
          maintainer_email
          home_page
          license
          summary
          description
          keywords
          platform
          download_url
      Arguments for different fields are combined using either "and"
      (the default) or "or".
      Example: search({'name': 'foo', 'description': 'bar'}, 'or').
      The results are returned as a list of dicts
      {'name': package name,
          'version': package release version,
          'summary': package release summary}