CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
querying.factory Class Reference

Public Member Functions

def __init__ (self, connection)
 
def object (self, class_name, **pkargs)
 

Public Attributes

 connection
 

Detailed Description

Contains methods for creating objects.

Definition at line 295 of file querying.py.

Constructor & Destructor Documentation

◆ __init__()

def querying.factory.__init__ (   self,
  connection 
)

Definition at line 299 of file querying.py.

299  def __init__(self, connection):
300  self.connection = connection
301 

Member Function Documentation

◆ object()

def querying.factory.object (   self,
  class_name,
**  pkargs 
)

Definition at line 305 of file querying.py.

305  def object(self, class_name, **pkargs):
306  from .data_sources import json_list
307  from .models import apply_filters
308  # get the class that self.connection holds from the class name
309  model = self.connection.model(class_name)
310 
311  if self.connection.session == None:
312  return None
313 
314  # query for the ORM object, and return the appropriate object (None, CondDBFW object, or json_list)
315  model_data = self.connection.session.query(model)
316  if len(pkargs.items()) != 0:
317  # apply the filters defined in **kwargs
318  model_data = apply_filters(model_data, model, **pkargs)
319  amount = pkargs["amount"] if "amount" in pkargs.keys() else None
320  model_data = model_data.limit(amount)
321  if model_data.count() > 1:
322  # if we have multiple objects, return a json_list
323  return json_list(model_data.all())
324  elif model_data.count() == 1:
325  # if we have a single object, return that object
326  return model_data.first()
327  else:
328  # if we have no objects returned, return None
329  return None
330  else:
331  # no column arguments were given, so return an empty object
332  new_object = model()
333  new_object.empty = True
334  return new_object
335 

References models.apply_filters(), querying.factory.connection, and ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi.model.

Member Data Documentation

◆ connection

querying.factory.connection

Definition at line 300 of file querying.py.

Referenced by querying.factory.object(), shell_tests.shell_tests.tearDown(), querying_tests.querying_tests.tearDown(), data_formats_tests.data_formats_tests.tearDown(), data_sources_tests.data_sources_tests.tearDown(), querying_tests.result_type_tests.tearDown(), querying_tests.tag_tests.test_all_tags_empty_tag(), querying_tests.tag_tests.test_all_tags_non_empty_tag(), querying_tests.querying_tests.test_check_connection(), data_formats_tests.data_formats_tests.test_dicts_to_orm_objects(), querying_tests.result_type_tests.test_factory_empty_result(), querying_tests.result_type_tests.test_factory_multiple_results(), querying_tests.result_type_tests.test_factory_no_result(), querying_tests.global_tag_map_tests.test_get_empty_global_tag_map(), querying_tests.iov_tests.test_get_empty_iov(), querying_tests.payload_tests.test_get_empty_payload(), querying_tests.tag_tests.test_get_empty_tag(), querying_tests.global_tag_map_tests.test_get_global_tag_map(), querying_tests.iov_tests.test_get_iov(), querying_tests.iov_tests.test_get_iovs_by_iov_query(), querying_tests.tag_tests.test_get_parent_global_tags(), querying_tests.payload_tests.test_get_parent_tags_payload(), querying_tests.payload_tests.test_get_payload(), querying_tests.tag_tests.test_get_tag(), data_formats_tests.data_formats_tests.test_orm_objects_to_dicts(), querying_tests.misc_tests.test_search_everything(), data_sources_tests.data_sources_tests.test_type_all_iovs(), data_sources_tests.data_sources_tests.test_type_all_tags(), data_sources_tests.data_sources_tests.test_type_parent_global_tags(), and querying_tests.payload_tests.test_type_parent_tags().

resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi.model
model
Definition: ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi.py:11
models.apply_filters
def apply_filters(orm_query, orm_class, **filters)
Definition: models.py:183