Commit b60fcb6f authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

query: Add wrapper for creating response object



It'll be used for querying locks.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent aa29e95f
......@@ -588,10 +588,7 @@ class _QueryBase:
"""Collect data and execute query.
"""
data = self._GetQueryData(lu)
return objects.QueryResponse(data=self.query.Query(data),
fields=self.query.GetFields()).ToDict()
return query.GetQueryResponse(self.query, self._GetQueryData(lu))
def OldStyleQuery(self, lu):
"""Collect data and execute query.
......
......@@ -235,6 +235,17 @@ def _PrepareFieldList(fields):
return result
def GetQueryResponse(query, ctx):
"""Prepares the response for a query.
@type query: L{Query}
@param ctx: Data container, see L{Query.Query}
"""
return objects.QueryResponse(data=query.Query(ctx),
fields=query.GetFields()).ToDict()
def QueryFields(fielddefs, selected):
"""Returns list of available fields.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment