Hi Giuseppe,<br><br><div class="gmail_quote">On Wed, May 23, 2012 at 1:24 PM, Giuseppe Sucameli <span dir="ltr"><<a href="mailto:brush.tyler@gmail.com" target="_blank">brush.tyler@gmail.com</a>></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've added a new tab "Project routines" 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'm also adding a safe-check, it asks to the user if enabling them.<br>
<br>
I've few questions:<br>
<br>
1. In [1] Martin wrote: """The routines should be able to access QGIS<br>
application with the use of the interface in the same way how plugins do""".<br>
I'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'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'm looking at adding editing access to code in my Plugin Editor plugin.<br>
<br>2) How about offering plugins the ability to programatically 'add' themselves to a project's open/save/close event? (In addition to running saved routines.)<br><br>Plugins could have standardized method 'hooks' (i.e. slots like initGui) for each event and only need to register with the user and the project'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'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's events without requiring a user to write any code, and allow the user to toggle a plugin's hook on/off/ignore, or deny a plugin'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'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's events.<br>
<br>Regards,<br></div><div><br>Larry Shaffer<br>Dakota Cartography<br>Black Hills, South Dakota <br></div></div><br>