def includeme(cls, config): """Setup the test configuration.""" allow, on, after = unpack.directives(config) config.add_engine_resource(model.Model, model.IContainer) s.register('CREATED', 'STARTED',) a.register('START',) IModel = model.IModel allow(IModel, a.START, (s.CREATED), s.STARTED) allow(IModel, a.START, (s.CREATED), s.STARTED)
def includeme(cls, config): """Setup the test configuration.""" # Unpack. allow, on, after = unpack.directives(config) # Traversal. config.add_engine_resource(model.Model, model.IContainer) config.add_engine_resource(model.Foo, model.IFooContainer) # Declare constants. s.register( 'CREATED', 'STARTED', 'FINISHED', 'FAILED', 'DISPUTED', ) a.register( 'START', 'FINISH', 'FAIL', 'DISPUTE', ) o.register( 'DOIT', ) r.register( 'SUCCESS', 'FAILURE', ) # Get a handle on the model interface. IModel = model.IModel IFoo = model.IFoo # Declare actions. allow(IModel, a.START, (s.CREATED), s.STARTED) allow(IModel, a.FINISH, (s.STARTED), s.FINISHED) allow(IModel, a.FAIL, '*', s.FAILED) allow(IModel, a.DISPUTE, '*', s.DISPUTED) # When started, kick off some operation... on(IModel, (s.STARTED), o.DOIT, ops.Dispatch()) # Bind the operation result to subsequent actions. after(IModel, o.DOIT, r.SUCCESS, a.FINISH) after(IModel, o.DOIT, r.FAILURE, a.FAIL) after(IFoo, o.DOIT, r.FAILURE, a.DISPUTE)
def add_notification(config, iface, role, state_or_action_changes, dispatch_mapping, delay=None): # Unpack. _, o, _, s = unpack.constants() _, on, _ = unpack.directives(config) o.register( 'CREATE_NOTIFICATION', ) create_notification_in_db = AddNotification(iface, role, dispatch_mapping, delay) on(iface, state_or_action_changes, o.CREATE_NOTIFICATION, create_notification_in_db)
def includeme(cls, config): """Setup the test configuration.""" # Unpack. allow, on, after = unpack.directives(config) # Traversal. config.add_engine_resource(model.Model, model.IContainer) config.add_engine_resource(model.Foo, model.IFooContainer) # Declare constants. s.register( 'CREATED', 'STARTED', 'POKED', ) a.register( 'START', 'POKE', ) o.register( 'BEEP', 'BEEP_A_LOT', 'GO_FORTH', 'MULTIPLY', ) # Get a handle on the model interface. IModel = model.IModel IFoo = model.IFoo # Declare actions. allow(IModel, a.START, (s.CREATED), s.STARTED) allow(IModel, a.POKE, '*', Ellipsis) allow(IFoo, a.POKE, '*', s.POKED) # Register s.STARTED state change subscribers. on(IModel, (s.STARTED), o.GO_FORTH, ops.Dispatch()) on(IFoo, (s.STARTED), o.MULTIPLY, ops.Dispatch()) # Register a catch all subscriber. on(IModel, '*', o.BEEP, ops.Dispatch()) # And an action subscriber. on(IFoo, a.POKE, o.BEEP_A_LOT, ops.Dispatch())
def add_notification(config, iface, state_or_action_changes, role, dispatch_mapping, delay=None, bcc=None): # Unpack. _, o, _, s = unpack.constants() _, on, _ = unpack.directives(config) o.register('CREATE_NOTIFICATION', ) create_notification_in_db = AddNotification(iface, role, dispatch_mapping, delay, bcc) on(iface, state_or_action_changes, o.CREATE_NOTIFICATION, create_notification_in_db)
def includeme(cls, config): """Setup the test configuration.""" # Unpack. allow, on, after = unpack.directives(config) # Traverse. config.add_engine_resource(model.Model, model.IContainer) # Declare constants. s.register( 'CREATED', 'STARTED', 'COMPLETED', 'ABSOLUTELY_COMPLETED', 'CANCELLED', 'TRANSMOGRIFIED', ) a.register( 'START', 'COMPLETE', 'CANCEL', 'POKE', 'TRANSMOGRIFY', ) # Get a handle on the model interface. IModel = model.IModel # Declare actions. allow(IModel, a.START, (s.CREATED), s.STARTED) allow(IModel, a.COMPLETE, (s.STARTED), s.COMPLETED) allow(IModel, a.COMPLETE, (s.COMPLETED), s.ABSOLUTELY_COMPLETED) allow(IModel, a.COMPLETE, (s.ABSOLUTELY_COMPLETED), Ellipsis) allow(IModel, a.CANCEL, (s.CREATED, s.STARTED), s.CANCELLED) allow(IModel, a.POKE, '*', Ellipsis) allow(IModel, a.TRANSMOGRIFY, '*', s.TRANSMOGRIFIED)
def includeme(cls, config): """Setup the test configuration.""" allow, on, after = unpack.directives(config) config.add_engine_resource(model.Model, model.IContainer) config.add_engine_resource(model.Foo, model.IFooContainer) s.register( 'CREATED', 'DRAFTED', 'PUBLISHED', 'PENDING_MODERATION', ) a.register( 'DRAFT', 'PUBLISH', 'APPROVE', 'POKE', ) allow(model.IModel, a.DRAFT, (s.CREATED), s.DRAFTED) allow(model.IModel, a.PUBLISH, (s.DRAFTED), s.PUBLISHED) allow(model.IFoo, a.PUBLISH, (s.DRAFTED), s.PENDING_MODERATION) allow(model.IFoo, a.APPROVE, (s.PENDING_MODERATION), s.PUBLISHED) allow(model.IFoo, a.POKE, '*', Ellipsis)