def _precharge(self): conn = pecan.request.db_conn try: precharge = conn.get_precharge_by_code(pecan.request.context, code=self.code) except Exception: LOG.error('Precharge(%s) not found' % self.code) raise exception.PreChargeNotFound(precharge_code=self.code) return precharge
def dispatched(self, data): conn = pecan.request.db_conn if data.remarks == wsme.Unset: data.remarks = None try: precharge = conn.dispatch_precharge(pecan.request.context, self.code, remarks=data.remarks) except exception.PreChargeNotFound: LOG.error('The precharge %s not found' % self.code) raise exception.PreChargeNotFound(precharge_code=self.code) except Exception as e: LOG.error('Fail to dispatch precharge(%s), for reason: %s' % (self.code, e)) raise exception.PreChargeException() return models.PreCharge.from_db_model(precharge)