diff options
author | Victor Sergeyev <vsergeyev@mirantis.com> | 2013-12-13 11:33:16 +0200 |
---|---|---|
committer | Victor Sergeyev <vsergeyev@mirantis.com> | 2014-02-21 16:49:09 +0200 |
commit | 52289ac48f7867a92051dc5ece05e992fe40a160 (patch) | |
tree | d8ffd3864e93474edb5a4ff77ea53006dca1d226 | |
parent | c19e86ee8198d3167b157c0f2f25a736e151258a (diff) | |
download | oslo-context-52289ac48f7867a92051dc5ece05e992fe40a160.tar.gz |
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
-rw-r--r-- | openstack/common/context.py | 11 |
1 files changed, 11 insertions, 0 deletions
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 |