/** * PyServlet's initialization can be performed as a ServletContextListener or as a regular * servlet, and this is the shared init code. If both initializations are used in a single * context, the system state initialization code only runs once. */ protected static void init(Properties props, ServletContext context) { String rootPath = getRootPath(context); context.setAttribute(INIT_ATTR, true); Properties baseProps = PySystemState.getBaseProperties(); // Context parameters Enumeration<?> e = context.getInitParameterNames(); while (e.hasMoreElements()) { String name = (String)e.nextElement(); props.put(name, context.getInitParameter(name)); } if (props.getProperty("python.home") == null && baseProps.getProperty("python.home") == null) { props.put("python.home", rootPath + "WEB-INF" + File.separator + "lib"); } PySystemState.initialize(baseProps, props, new String[0]); PySystemState.add_package("javax.servlet"); PySystemState.add_package("javax.servlet.http"); PySystemState.add_package("javax.servlet.jsp"); PySystemState.add_package("javax.servlet.jsp.tagext"); PySystemState.add_classdir(rootPath + "WEB-INF" + File.separator + "classes"); PySystemState.add_extdir(rootPath + "WEB-INF" + File.separator + "lib", true); }
public void init(Page owner, String zslang) { super.init(owner, zslang); if (System.getProperty("python.home") == null) System.setProperty("python.home", System.getProperty("java.io.tmpdir")); PySystemState.initialize(); PySystemState.add_extdir(owner.getDesktop().getWebApp().getRealPath("/WEB-INF/lib"), true); PySystemState.add_classdir(owner.getDesktop().getWebApp().getRealPath("/WEB-INF/classes")); _ip = new PythonInterpreter(new Variables()); }
public void init(Page owner, String zslang) { super.init(owner, zslang); if (System.getProperty("python.home") == null) System.setProperty("python.home", System.getProperty("java.io.tmpdir")); PySystemState.initialize(); PySystemState.add_extdir(owner.getDesktop().getWebApp().getRealPath("/WEB-INF/lib"), true); PySystemState.add_classdir(owner.getDesktop().getWebApp().getRealPath("/WEB-INF/classes")); _ip = new PythonInterpreter(new Variables()); }