def update_sizenormalization(model_id, sizenormalization, sizenormalization_id): sizenormalization.id = sizenormalization_id sizenormalization.account_id = model_id origeffectivedate = sizenormalization.effective_date sizenormalization.effective_date = pytz.UTC.localize( datetime.fromtimestamp(mktime(strptime(sizenormalization.effective_date[:10], "%Y-%m-%d")))) # fix datetime g.uow.size_normalizations.update(sizenormalization) # make a copy of the normalization to prevent the thread object's value from being changed while this thread continues on newnorm = SizeNormalization(sizenormalization.__dict__) # send the updating of records and compiling to a separate thread update_thread = UpdateNormalizationThread('size', newnorm) update_thread.start() sizenormalization.effective_date = origeffectivedate[:10] # zeroing out the time return json.dumps({"data": [sizenormalization.__dict__]})
def insert_pricenormalization(model_id, pricenormalization): print("insert") pricenormalization.id = str(uuid.uuid4()) # generate Guid origeffectivedate = pricenormalization.effective_date pricenormalization.effective_date = pytz.UTC.localize( datetime.fromtimestamp(mktime(strptime(pricenormalization.effective_date[:10], "%Y-%m-%d")))) # fix datetime pricenormalization.account_id = model_id pricenormalization.id = g.uow.price_normalizations.insert(pricenormalization) # make a copy of the normalization to prevent the thread object's value from being changed while this thread continues on newnorm = PriceNormalization(pricenormalization.__dict__) # send the updating of records and compiling to a separate thread update_thread = UpdateNormalizationThread('price', newnorm) update_thread.start() pricenormalization.effective_date = origeffectivedate[:10] # zeroing out the time return json.dumps({"data": [pricenormalization.__dict__]})