<p>Super, thx</p>
<p>Marco Bernasocchi (mobile)<br>
<a href="http://opengis.ch">http://opengis.ch</a></p>
<div class="gmail_quote">On Jul 10, 2012 1:07 PM, "Nathan Woodrow" <<a href="mailto:madmanwoo@gmail.com">madmanwoo@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hey All,<br>
<br>
This is a just a quick email to let everyone know that I have changed<br>
the way that arguments are passed to a layers Init Python function.<br>
That is the option that you find in the Layer Properties dialog on the<br>
General tab. If you are using this then this will affect you and you<br>
will know what I'm talking about.<br>
<br>
I have changed it so that the reference to the layer and feature are<br>
now passed into the function rather then just ids.  The issue with<br>
just passing the feature id was that you couldn't get access to the<br>
new feature and geometry because you were given a 0 as the id and 0 is<br>
a valid id for already existing feature.<br>
<br>
So now instead of this:<br>
<br>
def myFunction(dialog, layer_id, feature_id)<br>
<br>
where layer_id and feature_id are integers.  You now do this:<br>
<br>
def myFunction(dialog, layer, feature)<br>
<br>
layer is a instance of QgsVectorLayer<br>
feature is a instance of QgsFeature<br>
<br>
You can now do things like:<br>
<br>
def myFunction(dialog, layer, feature):<br>
      id = <a href="http://layer.id" target="_blank">layer.id</a>()<br>
      name = <a href="http://layer.name" target="_blank">layer.name</a>()<br>
      geom = feature.geometry()<br>
      geom.length()<br>
      # etc<br>
<br>
This change will break your custom form logic if your code is<br>
expecting a interger for the feature argument but you get a QgsFeature<br>
<br>
Just a FYI so you don't freak out when you form logic doesn't work anymore.<br>
<br>
- Nathan<br>
</blockquote></div>