# Path: giotto/middleware.py
# class GiottoOutputMiddleware(object):
#     def __init__(self, controller):
#         self.controller = controller


from giotto.middleware import GiottoOutputMiddleware
        from .models import Message

class AppendMessages(GiottoOutputMiddleware):
    def html(self, request, response):
        user = getattr(request, 'user', None)
        if not user:
            return response
        engine, template, context = response.data
        context['messages'] = Message.get(user=user)
        response.body = (engine, template, context)

# Path: giotto/middleware.py
# class GiottoOutputMiddleware(object):
#     def __init__(self, controller):
#         self.controller = controller


# Path: giotto/contrib/messages/middleware.py
from giotto.middleware import GiottoOutputMiddleware
        from .models import Message


class AppendMessages(GiottoOutputMiddleware):
    def html(self, request, response):
        user = getattr(request, 'user', None)
        if not user:
            return response
        engine, template, context = response.data
        context['messages'] = Message.get(user=user)
        response.body = (engine, template, context)

        return response