Skip to main content

Hi.

I've just built a custom Python based transformer, which utilizes two string attribute values.

One of the string had some embedded quotes ("), which were stripped before given to the Python code.

I tried swapping the quotes with single-quotes, but that crashed the Python execution entirely.

Is there really no automatic escaping of the entered values (into the transformer setup dialog) before passing them on ?

I managed to get it working by entering \\" (backslash-quote) in place of " (quote), but that's really a bad work-around. FME should really do that automagically by itself.

Cheers.

It's difficult to say without knowing more about how you're using the string attribute values.

Could you please post a sample workspace or some sample code that reproduces the issue?


It's difficult to say without knowing more about how you're using the string attribute values.

Could you please post a sample workspace or some sample code that reproduces the issue?

Sure. My transformer is included.

 

test-prependappend-transformer.fmwt

 


It's difficult to say without knowing more about how you're using the string attribute values.

Could you please post a sample workspace or some sample code that reproduces the issue?

The values in the transformer in the submitted template are escaped. Remove the backslashes to see the failure.

 

 


Sure. My transformer is included.

 

test-prependappend-transformer.fmwt

 

The linked custom transformer isn't available on my machine. You need to either post the transformer .fmx file here so I can install it, or embed the transformer into the workspace and repost.

It's difficult to say without knowing more about how you're using the string attribute values.

Could you please post a sample workspace or some sample code that reproduces the issue?

The transformer is included in the template. If this doesn't automatically make it available in the workspace, rename the .FMWT to .ZIP, and extract it from there.

 

 


Hi @lifalin2016, found the fmx, py files.

 

I think the following modification could resolve the problem.

 

  • In the fmx file, change the parameter type to "TEXT_ENCODED" if the parameter value could contain some special characters, such as double quotation.
  • In the Python script, decode the encoded parameter value with fmeobjects.FMESession.decodeFromFMEParsableText method.

It's difficult to say without knowing more about how you're using the string attribute values.

Could you please post a sample workspace or some sample code that reproduces the issue?

Hi @lifalin2016, found the fmx, py files.

 

I think the following modification could resolve the problem.

 

  • In the fmx file, change the parameter type to "TEXT_ENCODED" if the parameter value could contain some special characters, such as double quotation.
  • In the Python script, decode the encoded parameter value with fmeobjects.FMESession.decodeFromFMEParsableText method.

Hi @lifalin2016, found the fmx, py files.

 

I think the following modification could resolve the problem.

 

  • In the fmx file, change the parameter type to "TEXT_ENCODED" if the parameter value could contain some special characters, such as double quotation.
  • In the Python script, decode the encoded parameter value with fmeobjects.FMESession.decodeFromFMEParsableText method.
Hi Takashi.

 

Hmm, TEXT_ENCODED does not appear as a possible type in the docs about GUI-types !?

 

Is there another documentation to which only VIPs are privy ? :-)

 

Cheers

 

 


Hi @lifalin2016, found the fmx, py files.

 

I think the following modification could resolve the problem.

 

  • In the fmx file, change the parameter type to "TEXT_ENCODED" if the parameter value could contain some special characters, such as double quotation.
  • In the Python script, decode the encoded parameter value with fmeobjects.FMESession.decodeFromFMEParsableText method.
Please read the documentation more carefully. You would find the description like this.

 

_ENCODED.

 

This suffix means the value of the parameter will be WWJD encoded. ...

 

 

 


Please read the documentation more carefully. You would find the description like this.

 

_ENCODED.

 

This suffix means the value of the parameter will be WWJD encoded. ...

 

 

 

Ah, I was concentrating on the left hand pane, not realizing that general suffix modifiers were defined. Thanks Takashi for sharing this insight.

 

What about the fmeobjects.FMESession.decodeFromFMEParsableText method ?

 

I can find it in the Python reference, but would never have looked for it under FMESession. What's the reason for it being "hidden" here ?

 

Cheers.

 


Please read the documentation more carefully. You would find the description like this.

 

_ENCODED.

 

This suffix means the value of the parameter will be WWJD encoded. ...

 

 

 

Here.

 

http://docs.safe.com/fme/html/fmepython/api/fmeobjects/_utilities/fmeobjects.FMESession.decodeFromFMEParsableText.html#fmeobjects.FMESession.decodeFromFMEParsableText

 

 


Please read the documentation more carefully. You would find the description like this.

 

_ENCODED.

 

This suffix means the value of the parameter will be WWJD encoded. ...

 

 

 

FYI, the correct syntax is: fmeobjects.FMESession().decodeFromFMEParsableText(...)

 

 


Please read the documentation more carefully. You would find the description like this.

 

_ENCODED.

 

This suffix means the value of the parameter will be WWJD encoded. ...

 

 

 

I cannot accept your answer, until you've entered it as one such, Takashi :-)

 

 


Reply