def render(self, session, logger, city, country, fullname, comments, timezone, campus, **arguments): if country: dbparent = Country.get_unique(session, country, compel=True) else: dbparent = Campus.get_unique(session, campus, compel=True) dbcity = add_location(session, City, city, dbparent, fullname=fullname, comments=comments, timezone=timezone) session.flush() plenary = Plenary.get_plenary(dbcity, logger=logger) with plenary.get_key(): try: plenary.write(locked=True) dsdb_runner = DSDBRunner(logger=logger) dsdb_runner.add_city(city, dbcity.country.name, fullname) dsdb_runner.commit_or_rollback() except: plenary.restore_stash() raise return
def render(self, session, logger, city, country, fullname, comments, timezone, campus, **arguments): if country: dbparent = Country.get_unique(session, country, compel=True) else: dbparent = Campus.get_unique(session, campus, compel=True) dbcity = add_location(session, City, city, dbparent, fullname=fullname, comments=comments, timezone=timezone) session.flush() plenary = PlenaryCity(dbcity, logger=logger) key = plenary.get_write_key() try: lock_queue.acquire(key) plenary.write(locked=True) dsdb_runner = DSDBRunner(logger=logger) dsdb_runner.add_city(city, dbcity.country.name, fullname) dsdb_runner.commit_or_rollback() except: plenary.restore_stash() raise finally: lock_queue.release(key)
def render(self, session, logger, campus, country, fullname, comments, **arguments): dbcountry = Country.get_unique(session, country, compel=True) add_location(session, Campus, campus, dbcountry, fullname=fullname, comments=comments) session.flush() dsdb_runner = DSDBRunner(logger=logger) dsdb_runner.add_campus(campus, comments) dsdb_runner.commit_or_rollback() return
def render(self, session, country, **arguments): return Country.get_unique(session, country, compel=True)