+ with Session(self.engine) as session:
+ # Add some obvious store zones by default
+ DEFAULT_ZONES = {
+ 'Bakery': ['bread', 'cake', 'cookie', 'muffin', 'pie'],
+ 'Baking': ['flour', 'sugar'],
+ 'Books': ['book'],
+ 'Clothes': ['bra', 'coat', 'jacket', 'panties', 'pants', 'shirt', 'shorts', 'socks', 'sweater', 'underwear'],
+ 'Cooler': ['butter', 'cream', 'eggs', 'juice', 'milk', 'tea'],
+ 'Deli': ['beef', 'chicken', 'salmon', 'steak', 'turkey'],
+ 'Movies': ['movie', 'DVD'],
+ 'Music': ['cd', 'album'],
+ 'Produce': ['carrot', 'cucumber', 'greens', 'lettuce'],
+ 'Shoes': ['shoe'],
+ 'Television': ['tv', 'season'],
+ }
+ for zone in DEFAULT_ZONES:
+ logging.debug(f'Adding default items for {zone}')
+ for item in DEFAULT_ZONES[zone]:
+ try:
+ logging.debug(f'Attempt adding {item} to {zone}...')
+ new = ItemZone(name=item, zone=zone)
+ session.add(new)
+ session.commit()
+ logging.debug(f'Success adding {item} to {zone}...')
+ except Exception as ex:
+ session.rollback()
+ logging.debug(f'Failed adding {item} to {zone}: {ex}')
+