On Sun, 11 Dec 2011 15:26:55 +0100
Andreas Neumann <[email protected]> wrote:

> in javascript there is try and catch for such problems. Ore one could
> test if an object/method/property is present. There are a lot of
> browser differencies - so in a web environment it is quite normal to
> test for capabilities.
> 
> How can one check if an object/method is present in Python?

Hello Andreas, all,

the check can be done during import:

"""
try:
    from qgis.core import newFunctionName as function
except:
    from qgis.core import oldFunctionName as function
"""

so that you can use "function" anywhere in the code without further
checks.
To keep the import code short, only the previous version of the API is
tested. If a plugin developer wants to extend support to even older
versions, I would recommend to create a separate "LTS" version.
What do you think?

Anne
-- 
http://gis.cri.fmach.it/ghisla/

> 
> Andreas
> 
> On 12/11/2011 02:10 PM, Paolo Cavallini wrote:
> > Il 11/12/2011 10:57, Ziegler Stefan ha scritto:
> >> Hi
> >>
> >> What is the best practice to deal with such API breaks (regarding
> >> python plugins)? 
> > 
> > Can we have a conditional fix (if api_version=2.0)? This way we
> > should not maintain two copies of the same plugins, much better if
> > someone works with qgis stable but also tests master.
> > All the best.

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to