Apologies in advance for the long post...
I'm trying to write a java app with an embedded jython interpreter. The
purpose of the app is to generate configuration files for particular
machines. I'm not an expert in the format of the configuration files, so I
want other people (the real experts) to do that. I will be giving them a
reference to a java object that they will use as a context, to get
information from the java app (and the database) that they need to generate
the configuration file. (I'm using PythonInterpreter.set to set the context
and that works fine.)
Now, I would like to provide them a file (lets call it 'common") that they
can import into their file (lets call it 'specific') that has some basic
functionality so they don't have to worry about it, like opening and closing
files, printing strings to the file.
What I would like is to have a method I can invoke from the java app that I
provide in the common file that calls a method in their specific file. I
want that method to be in the common file because I want to open and close
the file, and I want to print out the version of my java app to the output
file before they print anything to the output file.
Here are the problems I have run into:
- The context, which is available in the specific file, isn't available in
the common file (scoping issue?)
- I want to provide a variable in the common file that would hold the 'go'
method in the specific file. The problem is that either the specific file
can't see the variable in the common file, or the common file can't find
method its reference holds. This looks like another scoping issue.
Am I on the right track? Need more info? I can also post the code, if
Any hints or references? I already have Jython Essentials and I have two
more jython books coming.
Get latest updates about Open Source Projects, Conferences and News.