def process_request(self, req):

        q = req.args.get('q')
        dirname, prefix = posixpath.split(q)
        prefix = prefix.lower()

        def kind_order(entry):
            return (not entry['id'], embedded_numbers(entry['id']))

        bm_entries = {'text': _('Favorites'),
                      'children': [],
                      }
        result = []

        # if no query then we only need to return the favorites.
        if not q:
            bm_entries['children'].extend({'id': bm.path,
                                           'text': bm.path,
                                           'is_favorite': True
                                           } for bm in VCSFavorite.select_all(self.env)
                                          )
            bm_entries['children'] = sorted(bm_entries['children'], key=kind_order)
            result.append(bm_entries)
            json = to_json(result)
            req.send(json, 'text/json')
            return

        repo_entries = self._get_vcs_folders(req, q, dirname, prefix)

        bm_entries['children'].extend({'id': bm.path,
                                       'text': bm.path,
                                       'is_favorite': True
                                       } for bm in VCSFavorite.select_all_path_begins_with(self.env, q)
                                      )

        for b_entry in bm_entries['children']:
            for r_entry in repo_entries['children']:
                if r_entry['text'] == b_entry['text'] or r_entry['text'] == (b_entry['text'] + '/'):
                    r_entry['is_favorite'] = True
                    break

        bm_entries['children'] = sorted(bm_entries['children'], key=kind_order)
        repo_entries['children'] = sorted(repo_entries['children'], key=kind_order)
        if bm_entries['children']:
            result.append(bm_entries)
        if repo_entries['children']:
            result.append(repo_entries)
        json = to_json(result)
        req.send(json, 'text/json')
 def process_request(self, req):
     path = req.args.get('path')
     VCSFavorite.remove_one_by_path(path, self.env)
     req.send('', 'text/plain')
 def process_request(self, req):
     path = req.args.get('path')
     favorite = VCSFavorite(self.env, path=path)
     favorite.insert()
     req.send('', 'text/plain')