Issue525092

classification
Title: disable package scan in registry
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: bckfnn Nosy List: bckfnn, otmarhumbel
Priority: normal Keywords: patch

Created on 2002-03-03.10:25:02 by otmarhumbel, last changed 2002-10-29.15:01:11 by bckfnn.

Messages
msg2225 (view) Author: Oti Humbel (otmarhumbel) Date: 2002-03-03.10:25:02
The idea of this patch is to allow easy disabling of 
the package scanning process in situations where it is 
not wanted, such as:
  - no write access to the file system
  - many concurrent users accessing the same jython 
installation

I tried to keep the patch as small as possible (only 
changing 2 lines in one file, and a new registry 
entry). Because the flag is only needed in one place, 
there is no change to Options.java.


The registry contains a new entry as follows:
  # Setting this property to false disables the 
package scan for the cachedir.
  # Please be aware that disabling this might break 
some import statements!
  python.package.scan = true


Changes to PySystemState.java (method initPackages
(Properties props)):

OLD:
10    private static void initPackages(Properties 
props) {
20       initCacheDirectory(props);
30        File pkgdir;
40        if (cachedir != null) {
50            pkgdir = new File(cachedir, "packages");
60        } else {
70            pkgdir = null;
80        }
90        packageManager = new SysPackageManager
(pkgdir, props);
100   }

NEW (add line 35 and modify line 40):
10    private static void initPackages(Properties 
props) {
20       initCacheDirectory(props);
30        File pkgdir;
*35       boolean packageScan =
*           props.getProperty
("python.package.scan", "true").equalsIgnoreCase
("true");
*40       if (cachedir != null && packageScan) {
50            pkgdir = new File(cachedir, "packages");
60        } else {
70            pkgdir = null;
80        }
90        packageManager = new SysPackageManager
(pkgdir, props);
100   }

msg2226 (view) Author: Oti Humbel (otmarhumbel) Date: 2002-03-05.15:37:53
Logged In: YES 
user_id=105844

Sorry but the two files javapath.py and javaos.py use 
import statements which are not compatible to the suggested 
patch:
This means that without a change to these 2 files, Jython 
21 can only be started if the package scan took place. We 
can fix that in applying the following changes.


javapath.py:
------------
replace 
  import java
with
  import sys
  sys.add_package( "java" )
  sys.add_package( "java.io" )
  sys.add_package( "java.lang" )
  

javaos.py:
----------
replace 
  import java
  from java.io import File, BufferedReader, 
InputStreamReader, IOException

with
  import sys   # move some lines upwards
  sys.add_package( "java" )
  sys.add_package( "java.io" )
  sys.add_package( "java.lang" )
  from java.io import BufferedReader
  from java.io import File
  from java.io import IOException
  from java.io import InputStreamReader
  from java.lang import Runtime
  from java.lang import System

and replace all occurrences of 'java.lang.' and 'java.io.' 
with '' (an empty string)

I hope this gives an idea!
Best wishes, 
Oti.
msg2227 (view) Author: Finn Bock (bckfnn) Date: 2002-10-29.15:01:11
Logged In: YES 
user_id=4201

Added to PySystemState.java: 2.77;

The property is called "python.cachedir.skip".

The issues for re-enabling import of java-packages for
javaos.py must be fixed outside of this patch.
History
Date User Action Args
2002-03-03 10:25:02otmarhumbelcreate