コード例 #1
0
ファイル: jsonrpc.py プロジェクト: EliAndrewC/ensconce
 def search(self, searchstr):
     """
     Perform a search for specified search string.
     
     :param searchstr: A string to match (exactly).
     :type searchstr: str
     :returns: A dict like {'resources': [r1,r2,...], 'groups': [g1,g2,...], 'passwords': [p1,p2,...]}
     :rtype: dict
     """
     results = search.search(searchstr)
     auditlog.log(auditlog.CODE_SEARCH, comment=searchstr)
     return {
         'resources':    [r.to_dict(decrypt=False) for r in results.resource_matches],
         'groups':       [r.to_dict() for r in results.group_matches],
         'passwords':    [r.to_dict(decrypt=False) for r in results.password_matches],
     }
コード例 #2
0
ファイル: __init__.py プロジェクト: EliAndrewC/ensconce
 def search(self, searchstr):
     r_matches = g_matches = p_matches = None
     if searchstr:
         (r_matches, g_matches, p_matches) = search.search(searchstr, include_encrypted=True)
         if len(r_matches) + len(g_matches) + len(p_matches) == 1:
             # There was only one result, so just send them to the resulting page.
             notify("Showing you the one result that matched your query.")
             if r_matches:
                 raise cherrypy.HTTPRedirect("/resource/view/{0}".format(r_matches[0].id))
             elif g_matches:
                 raise cherrypy.HTTPRedirect("/group/view/{0}".format(g_matches[0].id))
             elif p_matches:
                 # We could also redirect them to the password view/history page if that is more helpful?
                 raise cherrypy.HTTPRedirect("/resource/view/{0}".format(p_matches[0].resource_id)) 
         
         auditlog.log(auditlog.CODE_SEARCH, comment=searchstr)
     return render('search.html', {'resource_matches': r_matches,
                                   'group_matches': g_matches,
                                   'password_matches': p_matches,
                                   'searchstr': searchstr })