[Qgis-developer] Python dynamic forms

Jeremy Palmer JPalmer at linz.govt.nz
Thu Sep 16 01:21:45 EDT 2010


Hi All!

I'm trying to use custom forms for adding and editing features within a layers.

The forms that I'm creating need to query a PostgreSQL database to populate controls. Using the UI init function seems like the thing to do here. I've managed to populate the controls by setting up a new connection and executing the query from within this init function.

However these forms will be opened up all the time, and from a database administrators point of view I would like cache the database connection so a new connection is not created every time the form is opened. To make things more complicated I would like to share this connection across multiple feature forms within one QGIS user project. I also have a few other functions relating to the admin of these layers that I currently have in a plug-in which also needs the same database connection.

Is there a way to do connection caching with all of this? I thought about having a singleton class in my plug-in that stores this connection, but it looks like I can't access the plug-in registry from the PyQGIS api :(

Note I'm using psycopg2 for the database connections.

Thanks,
Jeremy

______________________________________________________________________________________________________

This message contains information, which is confidential and may be subject to legal privilege. 
If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message.
If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message.
LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ.

Thank you.
______________________________________________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20100916/229d16ba/attachment.html


More information about the Qgis-developer mailing list