docs: def set_model(model, tablename=None, created=None, appname=None, model_path=None):
      """
      Register an model and tablename to a global variable.
      model could be a string format, i.e., 'uliweb.contrib.auth.models.User'
  
      :param appname: if no appname, then archive according to model
  
      item structure
          created
          model
          model_path
          appname
  
      For dynamic model you should pass model_path with '' value
      """
      if isinstance(model, type) and issubclass(model, Model):
          #use alias first
          tablename = model._alias or model.tablename
      tablename = tablename.lower()
      #set global __models__
      d = __models__.setdefault(tablename, {})
      engines = d.get('config', {}).pop('engines', ['default'])
      if isinstance(engines, (str, unicode)):
          engines = [engines]
      d['engines'] = engines
      
      item = {}
      if created is not None:
          item['created'] = created
      else:
          item['created'] = None
      if isinstance(model, (str, unicode)):
          if model_path is None:
              model_path = model
          else:
              model_path = model_path
          if not appname:
              appname = model.rsplit('.', 2)[0]
          #for example 'uliweb.contrib.auth.models.User'
          model = None
      else:
          appname = model.__module__.rsplit('.', 1)[0]
          if model_path is None:
              model_path = model.__module__ + '.' + model.__name__
          else:
              model_path = ''
          #for example 'uliweb.contrib.auth.models'
          model.__engines__ = engines
          
      item['model'] = model
      item['model_path'] = model_path
      item['appname'] = appname
      d['model_path'] = model_path
      d['appname'] = appname
  
      for name in engines:
          if not isinstance(name, (str, unicode)):
              raise BadValueError('Engine name should be string type, but %r found' % name)
      
          engine_manager[name].models[tablename] = item.copy()