def txn(ticket): logging.info('Beginning transaction.') entity, natural = DataController.generateNaturalKind(ticket.subject) logging.info('Split natural kind. N: '+str(natural)+', E: '+str(entity)) if ticket.queue_indexing: logging.info('Indexing requested. Queueing request...') index_queue, index_task = IndexController.queueNewEntity(entity, return_task=True) index_task.add(index_queue.name, transactional=True) if ticket.queue_caching: logging.info('Caching requested. Queueing request...') cache_queue, cache_task = CacheController.queueNewEntity(entity, return_task=True) cache_task.add(cache_queue.name, transactional=True) ## @TODO: figure out way to merge descriptors in and put them too #if ticket.attachments is not None: # for item in ticket.attachments: # pass logging.info('Putting commit list...') return True
def data_put(models): _rpc = db.create_rpc(deadline=5, read_policy=db.EVENTUAL_CONSISTENCY) if isinstance(models, str): models = [models] puts_list = [] for model in models: entity, natural = DataController.generateNaturalKind(model) puts_list.append(entity) if natural is not None: puts_list.append(natural) return fn(models, rpc=_rpc)