def __init__(self,
               config,
               module_dict,
               app_code_path,
               imp_module=imp,
               os_module=os,
               dummy_thread_module=dummy_thread,
               pickle_module=pickle):
    """Initializer.

    Args:
      config: AppInfoExternal instance representing the parsed app.yaml file.
      module_dict: Module dictionary to use for managing system modules.
        Should be sys.modules.
      app_code_path: The absolute path to the application code on disk.
      imp_module, os_module, dummy_thread_module, etc.: References to
        modules that exist in the dev_appserver that must be used by this class
        in order to function, even if these modules have been unloaded from
        sys.modules.
    """
    self._config = config
    self._module_dict = module_dict
    self._imp = imp_module
    self._os = os_module
    self._dummy_thread = dummy_thread_module
    self._pickle = pickle
    self._indent_level = 0
    self._app_code_path = app_code_path
    self._white_list_c_modules = list(self._WHITE_LIST_C_MODULES)
    self._white_list_partial_modules = dict(self._WHITE_LIST_PARTIAL_MODULES)
    self._enabled_modules = []

    if self._config and self._config.runtime == 'python27':
      self._white_list_c_modules.extend(self._PY27_ALLOWED_MODULES)




      self._white_list_partial_modules['os'] = (
        list(self._white_list_partial_modules['os']) +
        ['getpid', 'getuid', 'sys'])


      for k in self._white_list_partial_modules.keys():
        if k.startswith('Crypto'):
          del self._white_list_partial_modules[k]


      webob_path = os.path.join(SDK_ROOT, 'lib', 'webob-1.1.1')
      if webob_path not in sys.path:
        sys.path.insert(1, webob_path)

      for libentry in self._config.GetAllLibraries():
        self._enabled_modules.append(libentry.name)
        extra = self.__PY27_OPTIONAL_ALLOWED_MODULES.get(libentry.name)
        logging.debug('Enabling %s: %r', libentry.name, extra)
        if extra:
          self._white_list_c_modules.extend(extra)
        if libentry.name == 'django':




          if 'django' not in self._module_dict:
            version = libentry.version
            if version == 'latest':
              django_library = appinfo._NAME_TO_SUPPORTED_LIBRARY['django']
              version = django_library.non_deprecated_versions[-1]
            if google.__name__.endswith('3'):


              try:
                __import__('django.v' + version.replace('.', '_'))
                continue
              except __HOLE__:
                sys.modules.pop('django', None)
            sitedir = os.path.join(SDK_ROOT,
                                   'lib',
                                   'django-%s' % version)
            if os.path.isdir(sitedir):
              logging.debug('Enabling Django version %s at %s',
                            version, sitedir)
              sys.path[:] = [dirname
                             for dirname in sys.path
                             if not dirname.startswith(os.path.join(
                               SDK_ROOT, 'lib', 'django'))]
              sys.path.insert(1, sitedir)
            else:
              logging.warn('Enabling Django version %s (no directory found)',
                           version)
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/dev_appserver_import_hook.py/HardenedModulesHook.__init__