def smisk_mvc_metadata(conf):
    '''This config filter configures the underlying Elixir 
    and SQLAlchemy modules.
    '''
    global log
    conf = conf.get('smisk.mvc.model')
    if not conf:
      return
    
    # Aquire required parameter "url"
    try:
      url = conf['url']
    except __HOLE__:
      log.warn('missing required "url" parameter in "smisk.mvc.model" config')
      return
    
    # Parse url into an accessible structure
    from smisk.core import URL, Application
    url_st = URL(url)
    
    # Make a copy of the default options
    engine_opts = default_engine_opts.copy()
    
    # MySQL
    if url_st.scheme.lower() == 'mysql':
      if 'poolclass' not in conf:
        conf['poolclass'] = MySQLConnectionPool
        log.debug('MySQL: setting poolclass=%r', conf['poolclass'])
        if 'pool_size' in conf:
          log.debug('MySQL: disabling pool_size')
          del conf['pool_size']
        if 'pool_size' in engine_opts:
          del engine_opts['pool_size']
      elif 'pool_recycle' not in conf and 'pool_recycle' not in engine_opts:
        # In case of user-configured custom pool_class
        conf['pool_recycle'] = 3600
        log.debug('MySQL: setting pool_recycle=%r', conf['pool_recycle'])
    elif 'poolclass' not in conf:
      # Others than MySQL should also use a kind of static pool
      conf['poolclass'] = SingleProcessPool
    
    # Demux configuration
    elixir_opts = {}
    for k,v in conf.items():
      if k.startswith('elixir.'):
        elixir_opts[k[7:]] = v
      elif k != 'url':
        engine_opts[k] = v
    
    # Apply Elixir default options
    if elixir_opts:
      log.info('applying Elixir default options %r', elixir_opts)
      # We apply by iteration since options_defaults is not 
      # guaranteed to be a real dict.
      for k,v in elixir_opts.items():
        options_defaults[k] = v
    
    # Mask out password, since we're logging this
    if url_st.password:
      url_st.password = '***'
    
    def rebind_model_metadata():
      # Dispose any previous connection
      if metadata.bind and hasattr(metadata.bind, 'dispose'):
        log.debug('disposing old connection %r', metadata.bind)
        try:
          metadata.bind.dispose()
        except Exception, e:
          if e.args and e.args[0] and 'SQLite objects created in a thread' in e.args[0]:
            log.debug('SQLite connections can not be disposed from other threads'\
              ' -- simply leaving it to the GC')
          else:
            log.warn('failed to properly dispose the connection', exc_info=True)
    
      # Create, configure and bind engine
      if engine_opts:
        log.info('binding to %r with options %r', str(url_st), engine_opts)
      else:
        log.info('binding to %r', str(url_st))
      metadata.bind = sql.create_engine(url, **engine_opts)
    
    # Queue action or call it directly
    if hasattr(Application.current, '_pending_rebind_model_metadata'):
      log.info('queued pending metadata rebind')
      Application.current._pending_rebind_model_metadata = rebind_model_metadata
    else:
      # Run in this thread -- might cause problems with thread-local stored connections
      rebind_model_metadata()
dataset/ETHPy150Open rsms/smisk/lib/smisk/mvc/model.py/smisk_mvc_metadata