Solved

Accessing FME Feature Attributes within a Python Caller


Badge +4

I am using a pythoncaller to access Zoom API to download unique meeting IDs.

 

The code is:

import ssl
 
import http.client
 
import zipfile
 
import fme
 
import fmeobjects
 
# Template Function interface:
 
# When using this function, make sure its name is set as the value of
 
# the 'Class or Function to Process Features' transformer parameter
 
def processFeature(feature):
 
  pass
 
 
 
# Template Class Interface:
 
# When using this class, make sure its name is set as the value of
 
# the 'Class or Function to Process Features' transformer parameter
 
class FeatureProcessor(object):
 
  def __init__(self):
 
    pass
 
  def input(self,feature):
 
    self.pyoutput(feature)
 
  def close(self):
 
    pass
 
 
 
#Setting User Parameters
 
MeetingID = "?????????"
 
 
 
conn.request("GET", "/v2/past_meetings/"+ MeetingID +"/instances", headers=headers)

What I would like to do is set MeetingID to feature.getAttribute('SCO_Zoom_Meeting_ID__c') where that is a value returned from a query from my database. 

 

I would appreciate any help. If I just set MeetingID = feature.getAttribute('SCO_Zoom_Meeting_ID__c') it errors saying 'feature' is not defined.

 

icon

Best answer by hkingsbury 19 May 2021, 22:10

View original

2 replies

Userlevel 5
Badge +29

The python caller will either call a class (line 29) or a function (line 17). From what I can guess from your scenario all you'll need is to use the function. This will get called once for each feature that gets passed through the transformer.

In that function is where you write your code, so line 47 onwards needs to be encapsulated in that function.

You will also need to set the transformer to call that function. There is a box at hte top of the window where you enter the function or class name. By default it is the class

Badge +4

Great! Thank you. That worked @hkingsbury​ 

Reply