<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Ok, I'm developing a processing plugin with two algorithms:</p>
    <ul>
      <li>The first algorithm: The user provides a number of
        informations about a <i>new</i> database. The algorithm creates
        the new database using the information - and creates postgis
        extension, schemas and some tables in the new database.<br>
        And lastly: it creates a database connection for the new
        database in QGIS.<br>
        <br>
      </li>
      <li>The second algorithm: The user chooses a database connection
        from a combobox created using the <i>QgsProcessingParameterProviderConnection</i>
        class. Finally the algorithm creates and populates a number of
        tables using the chosen connection <br>
      </li>
    </ul>
    <p>However: If you use the first algorithm to create the database
      and immediately uses the second algorithm trying to populate the
      new database, the connection is <i>not</i> listed in the
      combobox. </p>
    <p>I suspect it's because the <i>QgsProcessingParameterProviderConnection
      </i>is using the cached list of  connections when populating the
      dropdown list<i><br>
      </i></p>
    <p>Somewhat like this (in Python):</p>
    <p><font face="monospace">metadata =
        QgsProviderRegistry.instance().providerMetadata('postgres')<br>
        pg_connections = metadata.connections(cached=True) # Read the
        cached settings<br>
      </font></p>
    <p>I've had a similar problem in the past that was solved by
      changing the "cached=True" to "cached=False" thereby forcing a
      reread of the connection list. <br>
    </p>
    <p>If you restart QGIS after running algorithm no 1 and <i>then</i>
      runs algorithm no 2 it works like a charm.<br>
    </p>
    <p>My question: Is it possible to force <i>QgsProcessingParameterProviderConnection
      </i>to re-read the list of connections ? And, if possible, how ??</p>
    <br>
    <p><font face="monospace">-- </font></p>
    <pre class="moz-signature" cols="72">Med venlig hilsen / Best regards

Bo Victor Thomsen</pre>
  </body>
</html>