diff options
| -rw-r--r-- | gn_libs/privileges/authspec.py | 7 | ||||
| -rw-r--r-- | gn_libs/sqlite3.py | 9 |
2 files changed, 13 insertions, 3 deletions
diff --git a/gn_libs/privileges/authspec.py b/gn_libs/privileges/authspec.py index 2ae154f..2819f9d 100644 --- a/gn_libs/privileges/authspec.py +++ b/gn_libs/privileges/authspec.py @@ -167,10 +167,11 @@ def check(spec: str, privileges: tuple[str, ...]) -> bool: def privileges_fulfill_specs( - queried_privileges: tuple[str, ...], + resource_privileges: tuple[str, ...], + system_privileges: tuple[str, ...], resource_spec: str, system_spec: str ) -> bool: """Check whether a user's privileges fulfill the given specs.""" - return (check(resource_spec, queried_privileges) or - check(system_spec, queried_privileges)) + return (check(resource_spec, resource_privileges) or + check(system_spec, system_privileges)) diff --git a/gn_libs/sqlite3.py b/gn_libs/sqlite3.py index 78e1c41..565ed82 100644 --- a/gn_libs/sqlite3.py +++ b/gn_libs/sqlite3.py @@ -43,3 +43,12 @@ def cursor(conn: DbConnection) -> Iterator[DbCursor]: raise exc finally: cur.close() + + +def with_db_connection(db_uri: str, func: Callable[[DbConnection], Any]) -> Any: + """ + Call `func`, a function of one argument with the SQLite3 connection created + from the connection string `db_uri`. + """ + with connection(db_uri) as conn: + return func(conn) |
