From 52289ac48f7867a92051dc5ece05e992fe40a160 Mon Sep 17 00:00:00 2001 From: Victor Sergeyev Date: Fri, 13 Dec 2013 11:33:16 +0200 Subject: [PATCH] Add model_query() to db.sqlalchemy.utils module Added query helper - model_query() function. There are similar functions in Nova, Cinder, and other projects, so it makes sense to move this helper to common db code. POC in Nova - Ic14d2214c8ce16d6b22c6f31511aa6c0838aa17a Change-Id: I86e78eadc5a76d47452dfefbd4faef697d613b50 --- openstack/common/context.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/openstack/common/context.py b/openstack/common/context.py index 182b044..09019ee 100644 --- a/openstack/common/context.py +++ b/openstack/common/context.py @@ -98,3 +98,14 @@ def get_context_from_function_and_args(function, args, kwargs): return arg return None + + +def is_user_context(context): + """Indicates if the request context is a normal user.""" + if not context: + return False + if context.is_admin: + return False + if not context.user_id or not context.project_id: + return False + return True