Closed elemoine closed 7 years ago
The problem is Python3-specific. Here is a simple fix: https://github.com/geopython/pywps/compare/develop...elemoine:base64. I can create a PR if you think this is the correct way to fix it. Thanks.
Works for me, can you PR please?
Works for me, can you PR please?
Yes, I will.
@jachym the commit that you looked at solves the problem for inputs. But I've actually experienced the same problem on output. To solve the problem on the output side I had to use hasattr(self, 'data_format')
again. See the new commit that I've added to my base64 branch. I can create a PR but I am not sure you will like the use of hasattr
here again. I don't see any other way right now.
Hi @elemoine
well, I did not study computer science and all I know about programming theory is just taken from the ground on my way through life. Therefore please do not take my statements too ultimate - I certainly do not have strong opinion on most of programming patterns and anti patterns.
I'm not sure, whether checking from some class, whether there might be some attribute (introduced in child class) is good approach in OOP. I've prepared pull request for your branch https://github.com/elemoine/pywps/pull/2 which tries to choose little bit different approach: instead of checking for possible attribute in parent class (in this case IOHandler
), I've introduced new method, which can be overwritten in child classes (and so it's done in ComplexBase
class - the method returns openmode
based on your logic.
Does this work for you?
I've prepared pull request for your branch elemoine#2 which tries to choose little bit different approach: instead of checking for possible attribute in parent class (in this case IOHandler), I've introduced new method, which can be overwritten in child classes (and so it's done in ComplexBase class - the method returns openmode based on your logic.
The issue is that BasicComplex
, where you override get_open_mode
, is actually not a child class of IOHandler
. Instead, both are parent classes of ComplexInput
and ComplexOutput
. The override may work thanks to the order of classes in the inheritance definition, but this is fragile in my opinion.
So for now I think the simple approach used in my base64 branch is better. I am going to create a PR based on that branch.
Description
I get an exception when using the
file
handler on a complex input whose format is a base64-encoded image.The traceback:
Environment
Steps to reproduce
Here is a test process that can be used to reproduce the issue:
And a corresponding
Execute
request:And this is the command I use to post the request:
Additional information
The error occurs when writing the base64-decoded data into a file. For writing bytes the "binary" flag should be used when opening the file. It works if I use
open(stream_file_name, 'wb')
.