def getPriceNow(self, typeID): """Get price for provided typeID""" price = self.priceCache.get(typeID) if price is None: price = eos.db.getPrice(typeID) if price is None: price = types_Price(typeID) eos.db.add(price) self.priceCache[typeID] = price return price
def price(self): # todo: use `from sqlalchemy import inspect` instead (mac-deprecated doesn't have inspect(), was imp[lemented in 0.8) if self.__priceObj is not None and getattr(self.__priceObj, '_sa_instance_state', None) and self.__priceObj._sa_instance_state.deleted: pyfalog.debug("Price data for {} was deleted (probably from a cache reset), resetting object".format(self.ID)) self.__priceObj = None if self.__priceObj is None: db_price = eos.db.getPrice(self.ID) # do not yet have a price in the database for this item, create one if db_price is None: pyfalog.debug("Creating a price for {}".format(self.ID)) self.__priceObj = types_Price(self.ID) eos.db.add(self.__priceObj) eos.db.flush() else: self.__priceObj = db_price return self.__priceObj