|
From: <bc...@wo...> - 2001-02-09 11:01:38
|
[Brian Zhou]
>If we have a servlet.py that uses module.py, PyServlet only detects
>modification date of servlet.py but not any dependency modules.
>
>I don't expect an easy fix for managing all the dependencies. Instead
>I'm thinking maybe it would be helpful to just notify PyServlet to
>discard all the cache and use a new interpreter instance? Now I have to
>restart the servlet container to achieve that.
>
>Ideas?
How about:
1) We set an "pyservlet" attribute in the req object that references the
PyServlet dispatcher, and
2) We add a reset() method to PyServlet.
With these changes users can add a reset.py page with something like
this:
from javax.servlet.http import HttpServlet
class reset(HttpServlet):
def doGet(self, req, res):
req.getAttribute("pyservlet").reset()
req.getRequestDispatcher("/index.py").forward(req, res)
The reset() method contains:
public void reset() {
interp = new PythonInterpreter(null, new PySystemState());
cache.clear();
}
which will blow away both the name space and the sys.modules. This kind
of resetting is meant only as a crude debugging tool. There is certainly
state hidden away in static initializers and caches which is not reset
by this simple call.
regards,
finn
|