refactor to use same connection in middleware TODO: put connection in config pylons global