[Qgis-developer] SIP API Update merged. Attention plugin authors

Matthias Kuhn matthias.kuhn at gmx.ch
Mon Jun 10 08:19:01 PDT 2013


I have been working on a fix for this today, which is open as a pull
request at the moment [1]

We have been discussing this on IRC today, Main points:
On the C++ side, there are "invalid" and "NULL" QVariants. On the python
side there is only "None", therefore "QPyNullVariant" has been
introduced. As we could not see a reason for returning an invalid
attribute (if it's set it's a valid value or NULL) and QPyNullVariant
does not integrate nicely with other python code (e.g. python json
module maps None to NULL, put complains on QPyNullVariant) we decided to
map a "NULL" QVariant to "None" ( An Invalid QVariant would be mapped to
the same, but as that should not be returned anyway, that should not
happen )

Apart from this, it also updates the attribute related (set /get/
delete) methods to raise KeyErrors if a key is not available (the
getters returned an invalid QVariant so something had to happen here and
this behaviour seems appropriate).

I'm by no means a SIP expert, but it works fine here and I think it
looks good. If somebody with appropriate knowledge could have a look at
these changes I am glad.
If there is no objection I'm going to merge this soon.

Cheers
Matthias

[1] https://github.com/qgis/Quantum-GIS/pull/646

On 09.06.2013 16:01, Victor Olaya wrote:
> I am checking the SEXTANTE adaptation to the new SIP API, and
> everything is fine. The only "strange" thing that I found is how null
> values are handled when they appear in a vector layer field. It seems
> that, in that case, a QVariant is still returned (particularly a
> QPyNullVariant object). Wouldn't it be better to return a Python None
> instead, so in all cases Python values are returned?
>
> Cheers
>
> 2013/6/9 Richard Duivenvoorde <rdmailings at duif.net>:
>> On 09-06-13 10:47, Nathan Woodrow wrote:
>>> Technically this can be done for smaller plugins like Borys said.
>>>   Something like:
>>
>> I think only for VERY small plugins. In the (not so very big plugins) I do
>> it was already getting messy.
>>
>> And by the why, a big thank you for all the great work and decisions being
>> done lately! I really think 2.0 will be great \o/
>>
>> Richard
>>
>>
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer



More information about the Qgis-developer mailing list