docs: def make_application(debug=None, apps_dir='apps', project_dir=None,
      include_apps=None, debug_console=True, settings_file=None,
      local_settings_file=None, start=True, default_settings=None,
      dispatcher_cls=None, dispatcher_kwargs=None, debug_cls=None, debug_kwargs=None,
      reuse=True, verbose=False, pythonpath=None, trace_print=False):
      """
      Make an application object
      """
      from uliweb.utils.common import import_attr
      from uliweb.utils.whocallme import print_frame
      from werkzeug.debug import DebuggedApplication
  
      #is reuse, then create application only one
      if reuse and hasattr(SimpleFrame.__global__, 'application') and SimpleFrame.__global__.application:
          return SimpleFrame.__global__.application
  
      #process settings and local_settings
      settings_file = settings_file or os.environ.get('SETTINGS', 'settings.ini')
      local_settings_file = local_settings_file or os.environ.get('LOCAL_SETTINGS', 'local_settings.ini')
  
      dispatcher_cls = dispatcher_cls or SimpleFrame.Dispatcher
      dispatcher_kwargs = dispatcher_kwargs or {}
  
      if project_dir:
          apps_dir = os.path.abspath(os.path.normpath(os.path.join(project_dir, 'apps')))
      if not project_dir:
          project_dir = os.path.abspath(os.path.normpath(os.path.abspath(os.path.join(apps_dir, '..'))))
  
      if pythonpath:
          if isinstance(pythonpath, str):
              pythonpath = pythonpath.split(';')
          for x in pythonpath:
              if x not in sys.path:
                  sys.path.insert(0, x)
  
      if project_dir not in sys.path:
          sys.path.insert(0, project_dir)
  
      if apps_dir not in sys.path:
          sys.path.insert(0, apps_dir)
  
      install_config(apps_dir)
  
      if trace_print:
          output = sys.stdout
  
          class MyOut(object):
              def write(self, s):
                  output.write(s)
                  output.write('\n')
                  print_frame(output)
                  if hasattr(output, 'flush'):
                      output.flush()
  
          sys.stdout = MyOut()
  
      application = app = dispatcher_cls(apps_dir=apps_dir,
          include_apps=include_apps,
          settings_file=settings_file,
          local_settings_file=local_settings_file,
          start=start,
          default_settings=default_settings,
          reset=True,
          **dispatcher_kwargs)
  
      if verbose:
          log.info(' * settings file is "%s"' % settings_file)
          log.info(' * local settings file is "%s"' % local_settings_file)
  
      #settings global application object
      SimpleFrame.__global__.application = app
  
      #process wsgi middlewares
      middlewares = []
      parameters = {}
      for name, v in uliweb.settings.get('WSGI_MIDDLEWARES', {}).iteritems():
          order, kwargs = 500, {}
          if not v:
              continue
          if isinstance(v, (list, tuple)):
              if len(v) > 3:
                  logging.error('WSGI_MIDDLEWARE %s difinition is not right' % name)
                  raise uliweb.UliwebError('WSGI_MIDDLEWARE %s difinition is not right' % name)
              cls = v[0]
              if len(v) == 2:
                  if isinstance(v[1], int):
                      order = v[1]
                  else:
                      kwargs = v[1]
              else:
                  order, kwargs = v[1], v[2]
          else:
              cls = v
          middlewares.append((order, name))
          parameters[name] = cls, kwargs
  
      middlewares.sort(cmp=lambda x, y: cmp(x[0], y[0]))
      for name in reversed([x[1] for x in middlewares]):
          clspath, kwargs = parameters[name]
          cls = import_attr(clspath)
          app = cls(app, **kwargs)
  
      debug_flag = uliweb.settings.GLOBAL.DEBUG
      if debug or (debug is None and debug_flag):
          if not debug_cls:
              debug_cls = DebuggedApplication
  
          log.setLevel(logging.DEBUG)
          log.info(' * Loading DebuggedApplication...')
          app.debug = True
          app = debug_cls(app, uliweb.settings.GLOBAL.get('DEBUG_CONSOLE', False))
      return app