# Buggy code
def process_view(self, request, view_func, view_args, view_kwargs):
    """
    If a request path contains biz_cc_id parameter, check if current
    user has perm view_business or return http 403.
    """
    if getattr(view_func, "login_exempt", False):
        return None
    biz_cc_id = view_kwargs.get("biz_cc_id") or self._get_biz_cc_id_in_rest_request(
        request
    )
    if biz_cc_id and str(biz_cc_id) != "0":
        try:
            business = prepare_business(request, cc_id=biz_cc_id)
        except exceptions.Unauthorized:
            # permission denied for target business (irregular request)
            return HttpResponse(status=401)
        except exceptions.Forbidden:
            # target business does not exist (irregular request)
            return HttpResponseForbidden()
        except exceptions.APIError as e:
            ctx = {
                "system": e.system,
                "api": e.api,
                "message": e.message,
            }
            logger.error(json.dumps(ctx))
            return HttpResponse(status=503, content=json.dumps(ctx))

        # set time_zone of business
        if business.time_zone:
            request.session["blueking_timezone"] = business.time_zone

        if not request.user.has_perm("view_business", business):
            return HttpResponseForbidden()


# Traceback (ImportError)
------STARTING: Migrate Database------
Traceback (most recent call last):
File "manage.py", line 27, in <module>
execute_from_command_line(sys.argv)
File "/cache/.bk/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/cache/.bk/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 328, in execute
django.setup()
File "/cache/.bk/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/cache/.bk/env/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/cache/.bk/env/lib/python2.7/site-packages/django/apps/config.py", line 112, in create
mod = import_module(mod_path)
File "/cache/.bk/env/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/data/app/code/pipeline/apps.py", line 18, in <module>
from rediscluster import StrictRedisCluster
File "/cache/.bk/env/lib/python2.7/site-packages/rediscluster/__init__.py", line 7, in <module>
from .client import StrictRedisCluster, RedisCluster
File "/cache/.bk/env/lib/python2.7/site-packages/rediscluster/client.py", line 10, in <module>
from .connection import (
File "/cache/.bk/env/lib/python2.7/site-packages/rediscluster/connection.py", line 11, in <module>
from .nodemanager import NodeManager
File "/cache/.bk/env/lib/python2.7/site-packages/rediscluster/nodemanager.py", line 12, in <module>
from redis._compat import b, unicode, bytes, long, basestring
ImportError: cannot import name b
------FAILURE: Migrate Database------

# Fixed code
def process_view(self, request, view_func, view_args, view_kwargs):
    """
    If a request path contains biz_cc_id parameter, check if current
    user has perm view_business or return http 403.
    """
    if getattr(view_func, "login_exempt", False):
        return None
    biz_cc_id = view_kwargs.get("biz_cc_id") or self._get_biz_cc_id_in_rest_request(
        request
    )
    if biz_cc_id and str(biz_cc_id) != "0":
        try:
            business = prepare_business(request, cc_id=biz_cc_id)
        except exceptions.Unauthorized:
            # permission denied for target business (irregular request)
            return HttpResponse(status=401)
        except exceptions.Forbidden:
            # target business does not exist (irregular request)
            return HttpResponseForbidden()
        except exceptions.APIError as e:
            ctx = {
                "system": e.system,
                "api": e.api,
                "message": e.message,
            }
            logger.error(json.dumps(ctx))
            return HttpResponse(status=503, content=json.dumps(ctx))

        # set time_zone of business
        if business.time_zone:
            request.session["blueking_timezone"] = business.time_zone

        try:
            if not request.user.has_perm("view_business", business):
                raise exceptions.Unauthorized(
                    "user[{username}] has no perm view_business of business[{biz}]".format(
                        username=request.user.username, biz=business.cc_id
                    )
                )
        except Exception as e:
            logger.exception(
                "user[username={username},type={user_type}] has_perm raise error[{error}]".format(
                    username=request.user.username,
                    user_type=type(request.user),
                    error=e,
                )
            )
            return HttpResponseForbidden(e.message)