Consider the following test:
one.py:
globals = {'x': 0}
execfile('two.py', globals)
two.py:
print 'globals =', globals().keys()
output:
globals = ['x', '__builtins__']
This looks perfect to me. one.py executes two.py and passes it 'x' which is
obviously received as evidenced by the print statement.
Now in Webware/WebKit/ServletFactory.py we have the following snippet:
globals = {}
execfile(path, globals)
I changed globals to {'x': 0} and put a print statement at the top of
servlet file. The servlet reports it's globals as:
['__doc__', '__file__', '__name__', '__builtins__']
The 'x' doesn't show up and can't be used. Also, there are some extra
globals ('__doc__', '__file__', '__name__') that don't show up in the first
example. In fact, they remind me of modules, but I'm using execfile() not
one of the import functions or statements.
One other difference that comes to mind is that the ServletFactory resides
in a Python package and the my example one.py does not.
I'm using the latest CVS.
Anybody have any ideas on what gives?
My ultimate goal is to pass the transaction object into the servlet script
upon loading in case it needs access to special objects (like the
application or app server) at load time in order to initialize itself. This
is a nice, easy hook that could come in handy. Like in my current
project. :-)
-Chuck
|