def fill(self): db = get_session() for identifier, label in self.statuses.iteritems(): s = db.query(Status).filter_by(identifier=identifier).first() if not s: log.info("Creating status: %s", label) s = Status(identifier=identifier, label=toUnicode(label)) db.add(s) s.label = toUnicode(label) db.commit()
def fill(self): db = get_session() for identifier, label in self.statuses.iteritems(): s = db.query(Status).filter_by(identifier=identifier).first() if not s: log.info('Creating status: %s', label) s = Status(identifier=identifier, label=toUnicode(label)) db.add(s) s.label = toUnicode(label) db.commit()
def fill(self): try: db = get_session() for identifier, label in self.statuses.items(): s = db.query(Status).filter_by(identifier=identifier).first() if not s: log.info('Creating status: %s', label) s = Status(identifier=identifier, label=toUnicode(label)) db.add(s) s.label = toUnicode(label) db.commit() except: log.error('Failed: %s', traceback.format_exc()) db.rollback() finally: db.close()
def fill(self): try: db = get_session() for identifier, label in self.statuses.items(): s = db.query(Status).filter_by(identifier = identifier).first() if not s: log.info('Creating status: %s', label) s = Status( identifier = identifier, label = toUnicode(label) ) db.add(s) s.label = toUnicode(label) db.commit() except: log.error('Failed: %s', traceback.format_exc()) db.rollback() finally: db.close()