[Qgis-developer] SIP API Update

Nathan Woodrow madmanwoo at gmail.com
Thu May 30 19:48:11 PDT 2013


Etienne,

Basically QVariant no longer exits in PyQt so if you have from PyQt4.QtCore
import QVariant you can remove it, or if you have: myvalue = QVariant(10)
change it to myvalue = 10.

- Nathan


On Fri, May 31, 2013 at 12:41 PM, Nathan Woodrow <madmanwoo at gmail.com>wrote:

> Etienne,
>
> If self.attrStr() is something like QVariant(value) then you need to
> remove the QVariant() bit call.
>
> - Nathan
>
>
> On Fri, May 31, 2013 at 12:39 PM, Nathan Woodrow <madmanwoo at gmail.com>wrote:
>
>> Yeah they both return QVariant but that is auto converted to a Python
>> object by SIP.
>>
>> Not sure what is going on there I'll look into it.
>>
>> I get the right return result if I called feature.attribute().
>>
>> Which platform are you on?
>>
>> - Nathan
>>
>>
>> On Fri, May 31, 2013 at 12:30 PM, Etienne Tourigny <
>> etourigny.dev at gmail.com> wrote:
>>
>>>
>>>
>>> On Thu, May 30, 2013 at 3:12 AM, Nathan Woodrow <madmanwoo at gmail.com>wrote:
>>>
>>>> Hey all,
>>>>
>>>> I have decided to manage the SIP API update process so that we can have
>>>> it done by 2.0.  This is an important update as leaving it for later will
>>>> break every plugin yet again at later date which just leaves a really bad
>>>> taste for people to deal with. A few plugin authors have already expressed
>>>> that they would not be impressed having to do another major update again in
>>>> the future. And I agree.
>>>>
>>>> So having said that this is the current plan:
>>>>
>>>> - I have created a branch with the SIP API v2 update
>>>>  - Update all the core plugins in the sipapi-udate[0] branch over the
>>>> next couple of days
>>>> -  Merge into master
>>>>
>>>> I couldn't update all the core plugins myself BUT it would be a lot
>>>> easier if I could call on the plugin authors to run though their own code
>>>> and do the quick update.  The risk of me doing it is that I might break
>>>> something and not know it.  You know your code best so the help would be
>>>> greatly appreciated.
>>>>
>>>> I updated most of the console code and Salvatore has already cleaned
>>>> the rest up for me so that is one thing out of the way.
>>>>
>>>> And here comes the kicker: I would like to do this as quickly as we can
>>>> so to reduce the gap between master and the branch.  The sooner we merge it
>>>> to master the sooner we can open it to wider testing, but I don't expect to
>>>> run into any major issues when we do.
>>>>
>>>> If you are not aware of what benefits the SIP API update will bring
>>>> here is a quick example:
>>>>
>>>> Before:
>>>>
>>>> >>> str(yourlineedit.text().toString())
>>>> 'Hello World'
>>>> >>> feature["column"].toInt()[0]
>>>> 100
>>>>
>>>> After
>>>>
>>>> >>> yourlineedit.text()
>>>> 'Hello World'
>>>> >>> feature["column"]
>>>> 1000
>>>>
>>>
>>> I am trying to update a plugin (tileindex) using your branch and I get
>>> the following an error
>>>
>>>      fileName = feature[self.attrStr]
>>>
>>> TypeError: PyQt4.QtCore.QVariant represents a mapped type and cannot be
>>> instantiated
>>>
>>>
>>> It seems that feature[], as well as feature.attribute() return a
>>> QVariant (defined in qgsfeature.sip), which is incompatible with SIP API v2.
>>>
>>>
>>> How can this be fixed in the plugin or qgis?
>>>
>>>
>>>
>>>> It will make life for us and plugin authors a hell of a lot easier.
>>>>
>>>> I have put together a quick guide[1] with some examples.  It is open
>>>> edit so feel free to add any notes you have. It might be good to turn it
>>>> into a plugin translate guide for future plugin authors moving to 2.0.
>>>>
>>>> Regards,
>>>> Nathan
>>>>
>>>> [0] https://github.com/qgis/Quantum-GIS/tree/sipapi-update
>>>> [1]
>>>> https://docs.google.com/document/d/1S85DMEC71AOzTkF1_EpnF0dhVb2On2EVq4E5s1EXoNM/edit?usp=sharing
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Qgis-developer mailing list
>>>> Qgis-developer at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130531/cfd72e7d/attachment.html>


More information about the Qgis-developer mailing list