def upgrade(location=DEFAULT_LOCATION): # We don't want to fire any kind of events during a migration, # because "migrations are a low-level thing". from kotti import events events.clear() pkg_env = PackageEnvironment(location) revision = pkg_env.script_dir.get_current_head() print(u'Upgrading {0}:'.format(pkg_env.location)) def upgrade(rev, context): if rev == revision: print(u' - already up to date.') return [] print(u' - upgrading from {0} to {1}...'.format( rev, revision)) return context.script._upgrade_revs(revision, rev) pkg_env.run_env( upgrade, starting_rev=None, destination_rev=revision, ) print
def upgrade(location=DEFAULT_LOCATION, revision=None): # We don't want to fire any kind of events during a migration, # because "migrations are a low-level thing". from kotti import events events.clear() pkg_env = PackageEnvironment(location) if revision is None: revision = pkg_env.script_dir.get_current_head() print(u'Upgrading {0}:'.format(pkg_env.location)) def upgrade(heads, context): # alembic supports multiple heads, we don't. # initial revision is () in alembic >= 0.7 rev = heads[0] if heads else None if rev == revision: print(u' - already up to date.') return [] print(u' - upgrading from {0} to {1}...'.format(rev, revision)) return context.script._upgrade_revs(revision, rev) pkg_env.run_env( upgrade, starting_rev=None, destination_rev=revision, ) print
def upgrade(location=DEFAULT_LOCATION, revision=None): # We don't want to fire any kind of events during a migration, # because "migrations are a low-level thing". from kotti import events events.clear() pkg_env = PackageEnvironment(location) if revision is None: revision = pkg_env.script_dir.get_current_head() print(f"Upgrading {pkg_env.location}:") def upgrade(heads, context): # alembic supports multiple heads, we don't. # initial revision is () in alembic >= 0.7 rev = heads[0] if heads else None if rev == revision: print(" - already up to date.") return [] print(f" - upgrading from {rev} to {revision}...") return context.script._upgrade_revs(revision, rev) pkg_env.run_env(upgrade, starting_rev=None, destination_rev=revision) print()
def events(config): """sets up Kotti's default event handlers.""" from kotti.events import clear config.include("kotti.events") yield config clear()
def events(config): """ sets up Kotti's default event handlers. """ from kotti.events import clear config.include('kotti.events') yield config clear()
def tearDown(): from kotti.events import clear from kotti.message import _inject_mailer _inject_mailer[:] = [] clear() transaction.abort() testing.tearDown()
def tearDown(): from kotti import events from kotti import security from kotti.message import _inject_mailer # These should arguable use the configurator, so they don't need # to be torn down separately: events.clear() security.reset() _inject_mailer[:] = [] transaction.abort() testing.tearDown()
def test_subscribe(self, root, db_session): from kotti.events import ObjectEvent from kotti.events import clear from kotti.events import listeners from kotti.events import objectevent_listeners from kotti.events import subscribe from kotti.resources import Document def handler(event): pass dec = subscribe() dec.venusian = DummyVenusian() decorated = dec(handler) dec.register(None, None, handler) assert dec.evttype is object assert dec.objtype is None assert decorated == handler assert (handler, dec.register, 'kotti') in dec.venusian.attached assert handler in listeners[object] assert handler not in objectevent_listeners[object] clear() dec = subscribe(ObjectEvent) dec.venusian = DummyVenusian() decorated = dec(handler) dec.register(None, None, handler) assert dec.evttype is ObjectEvent assert dec.objtype is None assert decorated == handler assert (handler, dec.register, 'kotti') in dec.venusian.attached assert handler not in listeners[ObjectEvent] assert handler in objectevent_listeners[(ObjectEvent, None)] clear() dec = subscribe(ObjectEvent, Document) dec.venusian = DummyVenusian() decorated = dec(handler) dec.register(None, None, handler) assert dec.evttype is ObjectEvent assert dec.objtype is Document assert decorated == handler assert (handler, dec.register, 'kotti') in dec.venusian.attached assert handler not in listeners[ObjectEvent] assert handler in objectevent_listeners[(ObjectEvent, Document)]
def upgrade(location=DEFAULT_LOCATION): # We don't want to fire any kind of events during a migration, # because "migrations are a low-level thing". from kotti import events events.clear() pkg_env = PackageEnvironment(location) revision = pkg_env.script_dir.get_current_head() print(u'Upgrading {0}:'.format(pkg_env.location)) def upgrade(rev, context): if rev == revision: print(u' - already up to date.') return [] print(u' - upgrading from {0} to {1}...'.format(rev, revision)) return context.script._upgrade_revs(revision, rev) pkg_env.run_env( upgrade, starting_rev=None, destination_rev=revision, ) print
def tearDown(): _inject_mailer[:] = [] clear() transaction.abort() testing.tearDown()