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

def querying.factory.__init__ (   self,
  connection 
)

Definition at line 299 of file querying.py.

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

Member Function Documentation

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

Definition at line 305 of file querying.py.

References models.apply_filters().

Referenced by Vispa.Views.LineDecayView.LineDecayContainer.createObject(), Vispa.Views.LineDecayView.LineDecayContainer.delete(), Vispa.Views.LineDecayView.DecayLine.delete(), Vispa.Views.LineDecayView.LineDecayContainer.mouseReleaseEvent(), and Vispa.Views.BoxDecayView.BoxDecayContainer.toggleCollapse().

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 
def object(self, class_name, pkargs)
Definition: querying.py:305
def apply_filters(orm_query, orm_class, filters)
Definition: models.py:183

Member Data Documentation

querying.factory.connection