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
This commit is contained in:
parent
c19e86ee81
commit
52289ac48f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user