Hi Giuseppe,<br><br><div class="gmail_quote">On Wed, May 23, 2012 at 1:24 PM, Giuseppe Sucameli <span dir="ltr">&lt;<a href="mailto:brush.tyler@gmail.com" target="_blank">brush.tyler@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
I started to work on adding python support in project files (see [1]).<br>
<br>
I&#39;ve added a new tab &quot;Project routines&quot; to the project properties dialog<br>
where the user can define 3 different python routines:<br>
<br>
one is executed when the project is loaded,<br>
the next one when the project is saved,<br>
and the last one when the project is closed (saved or not).<br>
<br>
I&#39;m also adding a safe-check, it asks to the user if enabling them.<br>
<br>
I&#39;ve few questions:<br>
<br>
1. In [1] Martin wrote: &quot;&quot;&quot;The routines should be able to access QGIS<br>
application with the use of the interface in the same way how plugins do&quot;&quot;&quot;.<br>
I&#39;m wondering if those routines must be functions with a specific signature<br>
or they could just access the QGis interface using the qgis.utils.iface<br>
since I&#39;ll use the QgsPythonRunner to run them.<br>
<br>
2. In a loaded project with trusted scripts (the user has trusted them)<br>
if the user changes their definitions from project properties dialog<br>
2.a. should the new routines become active immediately when the user<br>
clicks on the apply button in the project properies dialog,<br>
2.b. or should become active when he saves the project (the new<br>
projectSaved script has to be called just after the project is saved),<br>
2.c. or should I keep the previous ones until the project is reloaded?<br>
<br>
3. should I call them project-embedded-scripts or routines??? :)<br>
<br>
Opinions are welcome.<br>
Cheers.<br>
<br>
[1] <a href="http://hub.qgis.org/wiki/quantum-gis/Google_Summer_of_Code_2012#Python-Support-in-Project-Files" target="_blank">http://hub.qgis.org/wiki/quantum-gis/Google_Summer_of_Code_2012#Python-Support-in-Project-Files</a><span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote><div><br>I apologize for posting before you have had your questions answered. This is an interesting feature and I have a question and suggestion for you.<br><br>1) Will the scripts/routines actually be embedded in the project file, or be as sidecar file(s)? I&#39;m looking at adding editing access to code in my Plugin Editor plugin.<br>
<br>2) How about offering plugins the ability to programatically &#39;add&#39; themselves to a project&#39;s open/save/close event? (In addition to running saved routines.)<br><br>Plugins could have standardized method &#39;hooks&#39; (i.e. slots like initGui) for each event and only need to register with the user and the project&#39;s settings. There could be a small table listing all plugins found to offer hooks for each event, with a enabling checkbox next to them (3 tables or 1 with mixed events).<br>
<br>When a user installs or launches a plugin, it could check it&#39;s enabled state for a project event and prompt user to authenticate its adding or toggling for that event. This would allow plugin authors to add their plugins to the project&#39;s events without requiring a user to write any code, and allow the user to toggle a plugin&#39;s hook on/off/ignore, or deny a plugin&#39;s request. Plugin authors would then have to handle user decisions/settings, and not annoy users with dialogs at every project event.<br>
<br>This is different than the plugin responding to any project&#39;s open/save/close Qt signal (only open is supported now in API?), and/or a plugin saving a setting in the project file, as it introduces standardized user preference and authentication across all plugins wanting access to a project&#39;s events.<br>
<br>Regards,<br></div><div><br>Larry Shaffer<br>Dakota Cartography<br>Black Hills, South Dakota <br></div></div><br>