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 293 of file querying.py.

Constructor & Destructor Documentation

def querying.factory.__init__ (   self,
  connection 
)

Definition at line 297 of file querying.py.

297  def __init__(self, connection):
298  self.connection = connection
299 
def __init__(self, connection)
Definition: querying.py:297

Member Function Documentation

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

Definition at line 303 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().

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

Member Data Documentation

querying.factory.connection