Update of /cvsroot/jython/jython/org/python/util
In directory usw-pr-cvs1:/tmp/cvs-serv11418
Modified Files:
PyServlet.java
Log Message:
- Added a reset() call.
- Added <context>/WEB-INF/jython to sys.path
- Added experimental support for the "javax.servlet.include.servlet_path"
attribute
Index: PyServlet.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/util/PyServlet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** PyServlet.java 2001/02/07 09:27:43 1.2
--- PyServlet.java 2001/02/10 11:12:13 1.3
***************
*** 61,69 ****
public class PyServlet extends HttpServlet {
private PythonInterpreter interp;
-
private Hashtable cache = new Hashtable();
public void init() {
! String rootPath = getServletContext().getRealPath("/");
Properties props = new Properties();
--- 61,70 ----
public class PyServlet extends HttpServlet {
private PythonInterpreter interp;
private Hashtable cache = new Hashtable();
+ private String rootPath;
+
public void init() {
! rootPath = getServletContext().getRealPath("/");
Properties props = new Properties();
***************
*** 80,84 ****
}
PythonInterpreter.initialize(System.getProperties(), props, new String[0]);
! interp = new PythonInterpreter();
PySystemState sys = Py.getSystemState();
--- 81,85 ----
}
PythonInterpreter.initialize(System.getProperties(), props, new String[0]);
! reset();
PySystemState sys = Py.getSystemState();
***************
*** 87,92 ****
sys.add_package("javax.servlet.jsp");
sys.add_package("javax.servlet.jsp.tagext");
-
- sys.path.append(new PyString(rootPath));
}
--- 88,91 ----
***************
*** 94,98 ****
throws ServletException, IOException
{
! String spath = ((HttpServletRequest) req).getServletPath();
String rpath = getServletContext().getRealPath(spath);
--- 93,101 ----
throws ServletException, IOException
{
! req.setAttribute("pyservlet", this);
!
! String spath = (String)req.getAttribute("javax.servlet.include.servlet_path");
! if (spath == null)
! spath = ((HttpServletRequest) req).getServletPath();
String rpath = getServletContext().getRealPath(spath);
***************
*** 105,110 ****
throw new ServletException("No python servlet found at:" + spath);
}
! private HttpServlet getServlet(String path)
throws ServletException, IOException
{
--- 108,125 ----
throw new ServletException("No python servlet found at:" + spath);
}
+
+ public void reset() {
+ interp = new PythonInterpreter(null, new PySystemState());
+ cache.clear();
+ PySystemState sys = Py.getSystemState();
+ sys.path.append(new PyString(rootPath));
+
+ String modulesDir = rootPath + File.separator +
+ "WEB-INF" + File.separator +
+ "jython";
+ sys.path.append(new PyString(modulesDir));
+ }
! private synchronized HttpServlet getServlet(String path)
throws ServletException, IOException
{
|