'Filter repositories per category by those that are valid for installing into Galaxy.'

@web.expose
def browse_valid_categories(self, trans, **kwd):

    galaxy_url = common_util.handle_galaxy_url(trans, **kwd)
    if galaxy_url:
        kwd['galaxy_url'] = galaxy_url
    if ('f-free-text-search' in kwd):
        if (kwd['f-free-text-search'] == 'All'):
            new_kwd = {}
            return self.valid_category_grid(trans, **new_kwd)
        if (('id' in kwd) and ('f-free-text-search' in kwd) and (kwd['id'] == kwd['f-free-text-search'])):
            try:
                name = kwd['id']
                repository = repository_util.get_repository_by_name(trans.app, name)
                kwd['id'] = trans.security.encode_id(repository.id)
            except:
                pass
        return self.browse_valid_repositories(trans, **kwd)
    if ('operation' in kwd):
        operation = kwd['operation'].lower()
        if (operation in ['valid_repositories_by_category', 'valid_repositories_by_user']):
            for (k, v) in kwd.items():
                if k.startswith('f-'):
                    del kwd[k]
            return trans.response.send_redirect(web.url_for(controller='repository', action='browse_valid_repositories', **kwd))
    title = trans.app.repository_grid_filter_manager.get_grid_title(trans, trailing_string='by    Category', default='Categories    of    Valid    Repositories')
    self.valid_category_grid.title = title
    return self.valid_category_grid(trans, **kwd)
