def get_tool_shed_repository_by_id(app, repository_id):
    """Return a tool shed repository database record defined by the id."""
    # This method is used only in Galaxy, not the tool shed.
    return app.install_model.context.query(app.install_model.ToolShedRepository) \
                                    .filter(app.install_model.ToolShedRepository.table.c.id == app.security.decode_id(repository_id)) \
                                    .first()