Beispiel #1
0
def bus(sqlite_session_factory):
    return messagebus.MessageBus(
        uow=unit_of_work.SqlAlchemyUnitOfWork(sqlite_session_factory),
        notifications=notifications.EmailNotifications(
            smtp_host=cfg['host'],
            port=cfg['port'],
        ),
        publish=lambda *_, **__: None)
Beispiel #2
0
def get_bus():
    uow = unit_of_work.SqlAlchemyUnitOfWork()
    bus = messagebus.MessageBus(
        uow=uow,
        notifications=notifications.EmailNotifications(),
        publish=publish)
    uow.set_bus(bus)
    return bus
Beispiel #3
0
from flask import Flask, jsonify, request
from allocation import (
    commands,
    exceptions,
    messagebus,
    notifications,
    orm,
    redis_pubsub,
    unit_of_work,
    views,
)

app = Flask(__name__)
orm.start_mappers()
bus = messagebus.MessageBus(uow=unit_of_work.SqlAlchemyUnitOfWork(),
                            notifications=notifications.EmailNotifications(),
                            publish=redis_pubsub.publish)


@app.route("/add_batch", methods=['POST'])
def add_batch():
    eta = request.json['eta']
    if eta is not None:
        eta = datetime.fromisoformat(eta).date()
    command = commands.CreateBatch(
        request.json['ref'],
        request.json['sku'],
        request.json['qty'],
        eta,
    )
    bus.handle([command])
Beispiel #4
0
def get_bus():
    return messagebus.MessageBus(
        uow=unit_of_work.SqlAlchemyUnitOfWork(),
        notifications=notifications.EmailNotifications(),
        publish=publish)