From 5ce88f219b7737a1c4838022dcbcbda7aab3ce3a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 07 2020 16:33:39 +0000 Subject: [PATCH 1/2] Append a '-' to the name provided when searching packages by their source name This way the LIKE query that is done will match - rather than all the packages starting with (which may results in foo1 being returned instead of foo). Fixes https://pagure.io/mdapi/issue/96 Signed-off-by: Pierre-Yves Chibon --- diff --git a/mdapi/__init__.py b/mdapi/__init__.py index ba0c131..3ac7ab7 100644 --- a/mdapi/__init__.py +++ b/mdapi/__init__.py @@ -90,7 +90,7 @@ async def _get_pkg(branch, name=None, action=None, srcname=None): pkg = [Packages(*item) for item in pkg] break elif srcname: - async with db.execute(GET_PACKAGE_BY_SRC, (srcname+'%',)) as cursor: + async with db.execute(GET_PACKAGE_BY_SRC, (srcname+'-%',)) as cursor: pkg = await cursor.fetchone() if pkg: pkg = Packages(*pkg) From 0cbc3e4f41ae1f95cef509ae8014774101550596 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 07 2020 16:35:25 +0000 Subject: [PATCH 2/2] Support newer werkzeug The version 1.0 of werkzeug has removed from of its import from the top level module, so now we need to look for them in their submodules. Signed-off-by: Pierre-Yves Chibon --- diff --git a/mdapi/__init__.py b/mdapi/__init__.py index 3ac7ab7..bf173fe 100644 --- a/mdapi/__init__.py +++ b/mdapi/__init__.py @@ -26,7 +26,7 @@ import logging import os import aiosqlite -import werkzeug +import werkzeug.utils from aiohttp import web @@ -46,7 +46,7 @@ from mdapi.db import ( CONFIG = dict() -obj = werkzeug.import_string('mdapi.default_config') +obj = werkzeug.utils.import_string('mdapi.default_config') for key in dir(obj): if key.isupper(): CONFIG[key] = getattr(obj, key)