[Pywps-dev] Subclassing processes

Luí­s Moreira de Sousa luis.de.sousa at protonmail.ch
Mon Apr 16 10:06:29 PDT 2018


Hi again David,

that is the quark, strangeness and charm of Python, class properties are simultaneously static and instance properties. If you are not aware of this, then yes, you might risk "misreferencing" properties. This usually happens when you invoke an instance property that has not yet been modified/assigned. I do not find think this to be a major problem, as long as you always access properties through the instances.

Cheers.

--
Luís Moreira de Sousa
Bowlespark 8
6701 DN Wageningen
The Netherlands
Phone: +31 628 544 755
Email: luis.de.sousa at protonmail.ch
RingID: ring:7ca91d83f4f9dec82fec9f1144b8e5c1ef2a110c
URL: https://ldesousa.github.io

Sent with [ProtonMail](https://protonmail.com) Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On April 16, 2018 3:40 PM, David Huard <huard.david at ouranos.ca> wrote:

> Hi Luis,
>
> Isn't there a risk for different Process instances to share the same Input instances ? It seems to me that that could lead to weird behavior.
>
> Cheers,
>
> David
>
> On Sat, Apr 14, 2018 at 2:18 PM Luí­s Moreira de Sousa <luis.de.sousa at protonmail.ch> wrote:
>
>> Hi David,
>>
>> I have done this in the past, pretty much as you say, by promoting the inputs and outputs objects to class properties. Other elements like title, abstract, etc, can be treated in the same way. This would all go into an "abstract" class from which actual process inherited. Perhaps there might be more elegant solutions, but to me this setting served well (I am a man of simple tastes).
>>
>> All that said, it could make sense defining inputs, outputs, etc as class properties in the Process class itself. Something to think about.
>>
>> Happy coding. Cheers.
>>
>> --
>> Luís Moreira de Sousa
>> Bowlespark 8
>> 6701 DN Wageningen
>> The Netherlands
>> Phone: +31 628 544 755
>> Email: luis.de.sousa at protonmail.ch
>> RingID: ring:7ca91d83f4f9dec82fec9f1144b8e5c1ef2a110c
>> URL: https://ldesousa.github.io
>>
>> Sent with [ProtonMail](https://protonmail.com) Secure Email.
>>
>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>> On April 11, 2018 11:51 PM, David Huard <huard.david at ouranos.ca> wrote:
>>
>>> Hi all,
>>>
>>> I often find myself in situations where it would be useful to subclass a Process and avoid copy-pasting shared inputs and outputs. The way most processes are written does not lend itself well to this, inputs being instance objects rather than class objects. I was wondering if any of you had experience with an elegant way to subclass pywps processes that is readable and does not pollute the class namespace too much.
>>>
>>> Thanks,
>>>
>>> david
>>
>> _______________________________________________
>> pywps-dev mailing list
>> pywps-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/pywps-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pywps-dev/attachments/20180416/db00adab/attachment.html>


More information about the pywps-dev mailing list