|
From: Robert W. B. <rb...@di...> - 2001-02-13 21:47:41
|
[Robert]
> >On an unrelated note, module global variables are common in the Jython
> >world. Is there an advantage to PyServlet if each servlet has it's own
> >namespace to accomodate this?
[Finn]
> Well, is there an advantage? I considered it when I added PyServlet to
> the repository, but for smallish apps, the application namespace is an
> advantage IMHO. For larger apps, the application probably have to deal
> with more controlled namespaces anyway.
Very true about the namespaces. I'm not sure about
advantages, but currently module globals work- until another PyServlet
tramples them. This seemed in need of a fix. The choices looked like
disallowing globals, or adding individual namespaces, so I started
playing with "interp.exec('servlet in dict')". Anyway, it
also seemed to be some compensation for not having class static methods.
Not a very strong case either way, so I thought I'd ask before wasting
time "fixing" something not thought to be broke.
[Robert]
> >Also, is it possible to use the Py
> >methods directly so you can use things like:
> >
> > Py.exec(PyObject o, PyObject globals, PyObject locals)
> >
> >instead of interp.exec("code in ns")?
[Finn]
> Sure, it is possible. What do you expect the advantages to be? I can't
> image any good things about executing a toplevel .py module with
> different globals/locals namespaces.
Just curious about an easier way to make servlets use a unique global
namespace. Py.exec(servlet, localNS, globalNS); looked promising and
cleaner than passing a servlet and namespace into the interpreter, then
calling interp.exec("servlet.method in namespace").
This depends on whether adding the unique namespaces was thought to be a
good thing to begin with. If not, it doesn't matter. If so,
implementing them looked like one of three options:
1. an interpreter instance per PyServlet- overkill?
2. extract and insert servlet and namespace into and from the interpreter
for each request- messy?
3. execute the file, class, and servlet methods with Py.exec methods-
visually appealing, but not common practice, maybe for a
reason I thought :)
I'm sure there's a better way that I'm missing though.
It sounds like there's no want for unique namespaces though.
I'll leave this until told otherwise.
Thanks,
-Robert
|