Syntax FACTORY_DEF PythonFactory [FACTORY_NAME ] [INPUT FEATURE_TYPE [ ]* []*]* SYMBOL_NAME [SOURCE_CODE ] [PYTHON_NAMESPACE FMEOBJECTS] [OUTPUT PYOUTPUT FEATURE_TYPE [ ]* []*]* Overview Note: This factory is not supported by FME Base Edition. The PythonFactory is an FME Factory whose functionality is implemented using the Python language. A PythonFactory is implemented using a python object that is specified by some symbol name. The symbol name must be fully qualified, and reference a valid Python object. Python Implementation Objects Three types of objects can be used to implement the factory: Python Classes Python Functions Python Instance Objects Python Class Implementation Either new-style or old style classes can be used to implement the factory. When a class object is used to implement the factory, the PythonFactory will create an instance of the class at runtime. The PythonFactory protocol is used to receive features from FME. PythonFactory Protocol Methods input(self,feature) Allows the implementation class to receive input features from FME. This method is only required if the factory needs to handle input features. Depending on the value of PYTHON_NAMESPACE, the feature parameter is an object of type pyfme.FMEFeature, or an fmeobjects.FMEFeature. Refer to the FME Objects API documentation for more information. This parameter is not an in/out parameter, i.e. any changes to the feature will be lost unless the feature is output using the self.pyoutput method. close(self) Called when the factory receives the "allDone" signal from FME, which indicates that the factory will not receive any further features. Bridge to FME Each implementation class can send features "over the bridge" to FME using the pyoutput method. The pyoutput(self,feature) method will be dynamically added to the instantiated class at runtime. Factory Styles Python Class implementations support implementation of the following factory styles. Single Input-Single Output The class defines an input method which processes each feature and immediately sends it back to FME via the self.pyoutput method. The class does not need to implement a close method. Single/Multiple Output Generator classes receive no input from FME, and therefore do not need to implement the input method. The class implements a 'close' method that generates multiple new features that are output using the self.pyoutput method. Single/Multiple Input Single/Multiple Output A combination of the previous two styles, this class can take one or more input features, and output. Python Function Implementation Python Functions can be used to implement factories that perform very simple operations on one feature at a time. The functionality provided is very similar to @Python. Functions implementing the factory must have a single parameter: an in/out feature parameter. Note: In contrast to the input method on class implementations, the feature parameter on function parameters is in/out; the feature object parameter is always returned back to FME as factory output. Python Object Implementation Python Object implementation is a slightly more complex variation on Class implementations. This manner of implementation allows the same class to be reused with slightly different initialization of the class. For example, a factory class that interacts with a Web Service may require the class to be initialized with user credentials prior to use. Assumptions FME supports Python 2.5 to 2.7. If an external Python installation is not chosen, FME will use a Python 2.7 install that ships as part of the standard FME installation. On Linux or Mac OS X, FME does not ship with Python - an external Python installation must be present. In addition, users of the PythonFactory should be familiar with fmeobjects, the Python wrapper to the FME Objects API. Clauses SYMBOL_NAME The fully-qualified name of a Python Function, Class, or Object that implements the factory. SOURCE_CODE Python source code that is encoded as described in Substituting Strings in Mapping Files, in the FME Fundamentals manual. For internal FME use by the PythonCaller. PYTHON_NAMESPACE The name of the FME Objects API to use. If not provided, the deprecated pyfme module is used. New PythonFactory implementations should specify PYTHON_NAMESPACE FMEOJBECTS to use the current API. Output Tags The PythonFactory supports the following output tag. PYOUTPUT Features passed to FME via the pyoutput method.