import reusable function from another snippet/python?

Questions about and code samples for automation process code snippets within Select.
Post Reply
toddsou
Posts: 75
Joined: Wed Jul 25, 2012 9:39 am

import reusable function from another snippet/python?

Post by toddsou »

Hi-

I have several snippets where they all do a similar thing, and so it occurred to me that I should refactor the code such that the reusable part can be called by all of them where they would simply pass a parameter for each caller to achieve its desired affect on the Order.

A's snippet:
Call R.DoThatThing(1);

B's snippet:
Call R.DoThatThing(2);

C's snippet:
Call R.DoThatThing(3);

R's snippet:
Define function DoThatThing(i) where maybe it adds an Order Note with a message including parameter i;


While it is straight forward to do this in Python via import, I'm not sure how to do this within the SPS automation snippet environment.

Thoughts?
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: import reusable function from another snippet/python?

Post by BobRichards »

We do not required that Python is installed on the customer's systems (neither client nor server) because of possible incompatibilities. Because of this, most standard Python import libraries are not available. We only support imports of the SoftPro libraries and .NET libraries available from the GAC. This makes the Python libraries (strictly speaking) unnecessary.

Using imports the way you want makes total sense - but it is not recommended. Snippets can be run on any server instance so while the snippet code is maintained on the server and downloaded to the instance as needed, the import files will not be downloaded and must be accessible from all servers.
Bob Richards, Senior Software Developer, SoftPro
Post Reply