szaszm commented on code in PR #1722:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1722#discussion_r1507552381


##########
extensions/python/types/PyProcessSession.cpp:
##########
@@ -308,6 +321,30 @@ PyObject* 
PyProcessSessionObject::transfer(PyProcessSessionObject* self, PyObjec
   Py_RETURN_NONE;
 }
 
+PyObject* 
PyProcessSessionObject::transferToCustomRelationship(PyProcessSessionObject* 
self, PyObject* args) {
+  auto session = self->process_session_.lock();
+  if (!session) {
+    PyErr_SetString(PyExc_AttributeError, "tried reading process session 
outside 'on_trigger'");
+    Py_RETURN_NONE;
+  }
+
+  PyObject* script_flow_file = nullptr;
+  const char* relationship_name = nullptr;
+  if (!PyArg_ParseTuple(args, "O!s", PyScriptFlowFile::typeObject(), 
&script_flow_file, &relationship_name)) {
+    throw PyException();
+  }
+
+  const auto flow_file = 
reinterpret_cast<PyScriptFlowFile*>(script_flow_file)->script_flow_file_.lock();
+  if (!flow_file) {
+    PyErr_SetString(PyExc_AttributeError, "tried reading FlowFile outside 
'on_trigger'");
+    Py_RETURN_NONE;
+  }
+
+  BorrowedStr name = BorrowedStr::fromTuple(args, 0);
+  session->transferToCustomRelationship(flow_file, relationship_name);

Review Comment:
   It may be worth null-checking and maybe empty-checking `relationship_name`, 
what do you think?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to