Revision: 3910
http://jython.svn.sourceforge.net/jython/?rev=3910&view=rev
Author: cgroves
Date: 2007-12-30 11:34:40 -0800 (Sun, 30 Dec 2007)
Log Message:
-----------
Add a section on JSR 223 to the userguide and do some general cleanup on things that caught my eye while going through the site. Moved the developer guide link to the one on the wiki since the one in here was out of date and only half complete
Modified Paths:
--------------
trunk/website/Project/contributors.txt
trunk/website/Project/userfaq.txt
trunk/website/Project/userguide.txt
trunk/website/left.nav
Removed Paths:
-------------
trunk/website/Project/devguide.txt
trunk/website/Project/patchadmin.txt
trunk/website/Project/randexposed.txt
trunk/website/Project/related.txt
Modified: trunk/website/Project/contributors.txt
===================================================================
--- trunk/website/Project/contributors.txt 2007-12-30 19:06:53 UTC (rev 3909)
+++ trunk/website/Project/contributors.txt 2007-12-30 19:34:40 UTC (rev 3910)
@@ -6,8 +6,11 @@
Active Commiters
----------------
+* James Baker
* Charlie Groves
* Otmar Humbel
+* Tobias Ivarsson
+* Philip Jenvey
* Alan Kennedy
* Samuele Pedroni
* Frank Wierzbicki
Deleted: trunk/website/Project/devguide.txt
===================================================================
--- trunk/website/Project/devguide.txt 2007-12-30 19:06:53 UTC (rev 3909)
+++ trunk/website/Project/devguide.txt 2007-12-30 19:34:40 UTC (rev 3910)
@@ -1,377 +0,0 @@
-==========================
- Jython Developer's Guide
-==========================
-
-.. contents:: Table of Contents
-
-Introduction
-============
-You might be interested in reading `Jim Hugunin's JPython paper`_,
-which appeared in the proceedings of the 6th International Python
-Conference.
-
-This is an introduction to developing Jython, just to get someone started. It doesn't cover in any depth the source code or the design behind Jython. It's purely aimed at getting a development environment setup. It's definitely not complete so feel free to make it better!
-
-The Wiki
-========
-Wiki http://wiki.python.org/jython/
-
-Mailing Lists
-=============
-Mailing Lists http://sourceforge.net/mail/?group_id=12867
-
-Subversion
-==========
-
-checkout
---------
-
-This checks out all of the jython subprojects (bugtests, jython -- the main codebase, sandbox etc.)
-
-::
-
- svn co https://jython.svn.sourceforge.net/svnroot/jython/trunk/
-
-* 2.1 Stable:
-
-::
-
- svn co https://jython.svn.sourceforge.net/svnroot/jython/tags/Release_2_1
-
-* 2.2 Alpha 1:
-
-::
-
- svn co https://jython.svn.sourceforge.net/svnroot/jython/tags/Release_2_2alpha1
-
-* Preparing a Patch on Unix command line: (note multiple changes can be concatencated into one patch file using >> as shown.
-
-::
-
- cvs -z3 -d:pserver:anonymous@... diff -u PyFloat.java >> patchfile.txt
-
-Python
-======
-
- * http://www.python.org/2.2.3/
- * Jython uses Python's standard library where possible. This means you will need a working copy of Python source files for the stdlib. We currently use Python 2.2 so you can grab the files from here if you don't already have 2.2 installed.
-
-
-JavaCC
-======
-
- * https://javacc.dev.java.net/
- * Parser generator for Java. Generally needed only for working on parser.
- * It's not really required that you install this so I'd skip it.
- * The latest version is JDK 1.5 compatible (uses 'e' rather than 'enum' as variable name).
-
-Ant
-===
-
- * http://ant.apache.org/ A Java-based build tool.
- * Eclipse users, see [wiki:Self:/JythonDeveloperGuide/EclipseNotes#ANT Eclipse ANT notes]
- * The Makefiles in the repository are old and will be removed.
- * Download the latest version and install so the bin/ is somewhere in your path.
- * The build.xml is the file containing the compiler directives
- * It uses a file called ant.properties to override default paths; here's mine:
-
- build.compiler=modern
- debug=on
- optimize=off
-
- javaccHome=/Users/bzimmer/Library/Java/Extras/javacc-3.2
-
- ht2html.dir=
- #python.home=
- python.lib=/sw/lib/python2.2
- python.exe=/sw/bin/python2.2
-
- ### zxJDBC ###
- oracle.jar=
- mysql.jar=/Users/bzimmer/Library/Java/Extras/mysql-connector-java-3.1.6-bin.jar
- informix.jar=
- postgresql.jar=/Users/bzimmer/Library/Java/Extras/pg74.215.jdbc2.jar
- jdbc.jar=
- servlet.jar=
-
-
-Jars
-====
-
- * Jython uses many optional jars
- * These are not required for building locally but are for deployment with the installer
- * The ant script takes care of conditional compilation
-
-IDEs
-====
-
- * Any Java IDE will work
- * IntelliJ
- * Eclipse see /EclipseNotes
- * Vim
- * ...
-
-Tests
-=====
-
-After you've built the project, you may want to set up an excutable file on your path to make it easy to launch your build of jython. This file will need to:
-
-* Set the python home property to the `dist` directory of your build (otherwise, you'll get import errors on the standard lib stuff).
-* Execute the `jython.jar` in the `dist` produced by the build.
-
-Here's a batch file that runs the built jython.jar (for windows): [[Anchor(sampleBatch)]]
-
-jytip.bat
-=========
-
-::
-
- @echo off
- set ARGS=
-
- :: concatenate all the command line args into one
- :loop
- if [%1] == [] goto end
- set ARGS=%ARGS% %1
- shift
- goto loop
- :end
-
- :: this is mine...
- :: java -Dpython.home=C:\\workspace\\JythonTip\\jython\\dist -jar
- ::<cont> c:\workspace\JythonTip\jython\dist\jython.jar %ARGS%
- :: fill in <placeholders> below:
- java -Dpython.home=<path to dist directory>\\dist -jar <path to dist directory>\dist\jython.jar %ARGS%
-
-
-Now your ready to run tests...
-
- * There are a couple different places to find test cases
- * Jython's Lib/test
- * Jython's bugtests repository
- * Python2.2's Lib/test
- * Run the particular test or you can run the whole suite by running `regrtest.py` with the `-a` option
-
-Directory layout
-================
-
- * src
- * com : zxJDBC related sources
- * org : top level package for python and apache (used for regex)
- * Demo : demo sources for the website and such
- * Doc : the website documentation
- * installer : the current installer.
- * Lib : the python source files for Jython standard library implementations
- * Lib/test : test cases
- * Misc : random scripts which are not all used; some generate source
- * Tools : JythonC and Freeze
-
-Coding Guidance
-===============
-
- * CodingStandards_ : The standards for writing Java code for Jython
- * JythonModulesInJava_ : How to write a Jython module in Java
- * JythonClassesInJava_ : How to write a Jython class in Java
-
-
-New Style Classes
-=================
-`Unifying types and classes in Python`_
-
-svn co jython/trunk/sandbox
-
-cd sandbox/jt
-
-There are two primary objectives:
-
- 1. expose the necessary methods for making an existing class 'new-style'
- 2. generating a wrapper class for subclasses in python to implement
-
-To do this there are two scripts:
-
- * gexpose.py (for exposing)
- * gderived.py (for deriving or subclassing)
-
-They each have a simple input language for determing exactly what to implement. Note that these .expose and .derived files are hand generated.
-
-For example, looking at a partial listing of list.expose:
-
-type_name: list
-type_class: PyList
-# exposed methods
-expose_meth: :- append o
-expose_meth: :i count o
-expose_meth: pop i?
-expose_meth: :b __nonzero__
-
-So the type_name is 'list'.
-
->>> type([])
-<type 'list'>
-
-It is intended to expose methods for PyList.
-
- * It exposes the method 'append' which takes a PyObject and returns void.
- * It exposes the method 'count' which takes a PyObject and returns an int.
- * It exposes the method 'pop' which takes an optional int and returns a PyObject.
- * It exposes the method '__nonzero__' which takes no arguments and returns a boolean.
-
-Running gexpose.py produces some Java code.
-
-$ python gexpose.py list.expose > list.txt
-
-Opening the file list.txt in your favorite editor you'll see the Java code. This code should then be pasted into the class PyList at the top of the file. This will result in a slew of compiler problems.
-
-The problem is PyList doesn't have any of the methods. The generated code expected 'list_append' but PyList has only 'append' so the compiler complains. This is intended. Now for the boring part. For each method exposed, we need to create a new method. For example:
-
-::
-
- public void append(PyObject o) {
- list_append(o);
- }
-
- final void list_append(PyObject o) {
- resize(length+1);
- list[length-1] = o;
- }
-
-Notice the new method is final and package protected. So follow the pattern for each method that needs to be exposed.
-
-The special method __init__ should delegate to 'list_init' which needs to handle the constructor arguments of a list. If there is no argument, create a new list. If an argument, copy it's contents to a new list.
-
-Make sure the class has a constructor which takes a PyType.
-
-Finally, make sure the type is registered with __builtin__.
-
- * It should also be noted an existing 'list' was registered which provided the construction of a new list under the old scheme. I moved this code to PyList and deleted it from __builtin__. This is much better since all list construction now happens in one spot.
-
-Run some quick tests:
-
->>> list()
-[]
->>> list([1,2,3])
-[1, 2, 3]
->>> type([])
-<type 'list'>
->>> list
-<type 'list'>
->>>
-
-After that was done, run the regrtest and the bugtests. The bugtests caught a bug in my original effort. I had forgotten to make the constructor with PyType argument so any list(arg) call failed quickly as the PyType instance was the argument to the PyList(PyObject) constuctor and since PyType is not iterable, the call failed. The tests were great in tracking this down.
-
-Another Newstyle Class Example: Implementing the _random module
-===============================================================
-
-Module
-------
-
-Start by writing a class to represent the module, I'll call it RandomModule.
-::
-
- package org.python.modules.random;
-
- import org.python.core.ClassDictInit;
- import org.python.core.Py;
- import org.python.core.PyObject;
-
- public class RandomModule implements ClassDictInit {
-
- private RandomModule() {}
-
- public static void classDictInit(PyObject dict) {
- dict.__setitem__("Random", Py.java2py(PyRandom.class));
- }
- }
-
-.. Note: ClassDictInit is the old style way for initializing the class dictionary -- need to see if there is
- a newstyle way to create a module.
-
-put module into builtin
------------------------
-
-Next add this line to the builtinModules method of org.python.modules.Setup, to put _random into the builtin namespace:
-
- "_random:org.python.module.random.RandomModule"
-
-Next we create a stub for the "Random" object. I'm going to call it PyRandom since it will depend on
-java.util.Random and I don't want to have to qualify the "Random" name throughout the code.
-
-::
-
- package org.python.modules.random;
-
- import org.python.core.PyObject;
- import org.python.core.PyType;
- import java.util.Random;
-
- public class PyRandom extends PyObject {
- //~ BEGIN GENERATED REGION -- DO NOT EDIT SEE gexpose.py
- //~ END GENERATED REGION -- DO NOT EDIT SEE gexpose.py
-
- private static final PyType RANDOMTYPE = PyType.fromClass(PyRandom.class);
-
- public PyRandom() {
- this(RANDOMTYPE);
- }
-
- public PyRandom(PyType subType) {
- super(subType);
- }
-
- }
-
-Create a random.expose file
----------------------------
-Found the methods of _random.Random from CPython's _randommodule.c
-
->>> import _random
->>> dir(_random)
-['Random', '__doc__', '__file__', '__name__']
->>> dir(_random.Random)
-['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'getrandbits', 'getstate', 'jumpahead', 'random', 'seed', 'setstate']
-
-::
-
- # setup
- type_name: random
- type_class: PyRandom
- # exposed methods
- expose_meth: random
- expose_meth: seed o?
- expose_meth: :o getstate
- expose_meth: setstate o
- expose_meth: jumpahead
- expose_meth: getrandbits
- expose_meth: __reduce__
- #expose_meth: __reduce_ex__
- expose_meth: __repr__
- expose_meth: __str__
- expose_new_mutable:
- expose_wide_meth: __init__ -1 -1
- `vdeleg`(init);
- `void;
-
-Then execute:
-::
-
- gexpose.py random.expose /path/to/file/PyRandom.java
-
-which will modify PyRandom.java in place and produce `this version of PyRandom`_
-
-Then we need to fill out all of those methods. for each of the methods that
-start with `random_`, we also need to implement a bare version for Java
-subclassing.
-
-org.python.modules.random.PyRandom is in the 2.3 branch, but is a stub implementation.
-If you are interested in implementing it please say so on the jython-dev list.
-
-Create a random.derived file
-----------------------------
-
-.. _Jim Hugunin's JPython paper: http://www.python.org/workshops/1997-10/proceedings/hugunin.html
-.. _CodingStandards: http://wiki.python.org/jython/CodingStandards
-.. _JythonModulesInJava: http://wiki.python.org/jython/JythonModulesInJava
-.. _JythonClassesInJava: http://wiki.python.org/jython/JythonClassesInJava
-.. _Unifying types and classes in Python:
-.. _this version of PyRandom: randexposed.html
-
Deleted: trunk/website/Project/patchadmin.txt
===================================================================
--- trunk/website/Project/patchadmin.txt 2007-12-30 19:06:53 UTC (rev 3909)
+++ trunk/website/Project/patchadmin.txt 2007-12-30 19:34:40 UTC (rev 3910)
@@ -1,77 +0,0 @@
-========================
-Patch Manager Guidelines
-========================
-
-Intended use of SourceForge patch Resolution, Status & "Assigned To" fields Revision 4 16-Mar-2001
-
-In general, the Resolution and Status fields should be close to self-explanatory, and the "Assigned to:" field should be the person responsible for taking the next step in the patch process. Both fields are expected to change value over the life of a patch; the normal workflow is detailed below.
-
-When you've got the time and the ability, feel free to move any patch that catches your eye along, whether or not it's been assigned to you. And if you're assigned to a patch but aren't going to take reasonably quick action (for whatever reason), please assign it to someone else ASAP: at those times you can't actively help, actively get out of the way.
-
-If you're an expert in some area and know that a patch in that area is both needed and non-controversial, just commit your changes directly -- no need then to get the patch mechanism involved in it.
-
-You should add a comment to every patch assigned to you at least once a week, if only to say that you realize it's still on your plate. This rule is meant to force your attention periodically: patches get harder & harder to deal with the longer they sit.
-
-Status Open, Resolution None
-============================
-
-The initial state of all patches. The patch is under consideration, but has not been reviewed yet, or s under review but not yet Accepted or Rejected.
-
-The Resolution will normally change to Accepted or Rejected next. The person submitting the patch should (if they can) assign it to the person they most want to review it.
-
-Else the patch will be assigned via [xxx a list of expertise areas should be developed] [xxx but since this hasn't happened and volunteers are too few, andom assignment is better than nothing: if you're a Jython developer, expect to get assigned out of the blue!]
-
-Discussion of major patches is carried out on the Jython-Dev mailing list. For simple patches, the SourceForge comment mechanism should be sufficient. [xxx an email gateway would be great, ditto Ping's Roundup] For the reviewer: If you're certain the patch should be applied, change the Resolution to Accepted and assign it back to the submitter (if possible) for checkin. If you're certain the patch should never be accepted, change the Resolution to Rejected, Status to Closed, and assign it to None.
-
-If you have specific complaints that would cause you to change your mind, explain them clearly in a comment, leave the status Open, and reassign back to the submitter. If you're uncertain, leave the status Open, explain your uncertainties in a comment, and reassign the patch to someone you believe can address your remaining questions; or leave the status Open and bring it up on Jython-Dev.
-
-Status Open, Resolution Accepted
-================================
-
-The powers that be accepted the patch, but it hasn't been applied yet. [xxx flesh out -- Guido Bottleneck avoidable here?]
-
-The Status will normally change to Closed next.
-
-The person changing the Resolution to Accepted should, at the same time, assign the patch to whoever they believe is most likely to be able & willing to apply it (the submitter if possible).
-
-Status Closed, Resolution Accepted
-==================================
-
-The patch has been accepted and applied.
-
-The previous Resolution was Accepted, or possibly None if the submitter was Guido (or moral equivalent in some particular area of expertise).
-
-Status Closed, Resolution Rejected
-==================================
-
-The patch has been reviewed and rejected.
-
-There are generally no transitions out of this state: the patch is dead.
-
-The person setting this state should also assign the patch to None.
-
-Status Open, Resolution Out of date
-===================================
-
-Previous Resolution was Accepted or Postponed, but the patch no longer works.
-
-Please enter a comment when changing the Resolution to "Out of date", to record the nature of the problem and the previous state.
-
-Also assign it back to the submitter, as they need to upload a new version.
-
-Status Open, Resolution Postponed
-=================================
-
-The previous Resolution was None or Accepted, but for some reason (e.g., pending release) the patch should not be reviewed or applied until further notice.
-
-The Resolution will normally change to None or Accepted next.
-
-Please enter a comment when changing the Resolution to Postponed, to record the reason, the previous Resolution, and the conditions under which the patch should revert to Resolution None or Accepted. Also assign the patch to whoever is most likely able and willing to decide when the state should change again.
-
-Status Deleted
-==============
-
-Bit bucket.
-
-Use only if it's OK for the patch and its SourceForge history to disappear. As of 09-July-2000, SF does not actually throw away Deleted patches, but that may change.
-
Deleted: trunk/website/Project/randexposed.txt
===================================================================
--- trunk/website/Project/randexposed.txt 2007-12-30 19:06:53 UTC (rev 3909)
+++ trunk/website/Project/randexposed.txt 2007-12-30 19:34:40 UTC (rev 3910)
@@ -1,260 +0,0 @@
-::
-
- package org.python.modules.random;
-
- import java.util.Random;
- import org.python.core.PyObject;
- import org.python.core.PyType;
-
- public class PyRandom extends PyObject {
- //~ BEGIN GENERATED REGION -- DO NOT EDIT SEE gexpose.py
- /* type info */
-
- public static final String exposed_name="random";
-
- public static void typeSetup(PyObject dict,PyType.Newstyle marker) {
- class exposed_random extends PyBuiltinFunctionNarrow {
-
- private PyRandom self;
-
- public PyObject getSelf() {
- return self;
- }
-
- exposed_random(PyRandom self,PyBuiltinFunction.Info info) {
- super(info);
- this.self=self;
- }
-
- public PyBuiltinFunction makeBound(PyObject self) {
- return new exposed_random((PyRandom)self,info);
- }
-
- public PyObject __call__() {
- return self.random_random();
- }
-
- public PyObject inst_call(PyObject gself) {
- PyRandom self=(PyRandom)gself;
- return self.random_random();
- }
-
- }
- dict.__setitem__("random",new PyMethodDescr("random",PyRandom.class,0,0,new exposed_random(null,null)));
- class exposed_seed extends PyBuiltinFunctionNarrow {
-
- private PyRandom self;
-
- public PyObject getSelf() {
- return self;
- }
-
- exposed_seed(PyRandom self,PyBuiltinFunction.Info info) {
- super(info);
- this.self=self;
- }
-
- public PyBuiltinFunction makeBound(PyObject self) {
- return new exposed_seed((PyRandom)self,info);
- }
-
- public PyObject __call__(PyObject arg0) {
- return self.random_seed(arg0);
- }
-
- public PyObject inst_call(PyObject gself,PyObject arg0) {
- PyRandom self=(PyRandom)gself;
- return self.random_seed(arg0);
- }
-
- public PyObject __call__() {
- return self.random_seed();
- }
-
- public PyObject inst_call(PyObject gself) {
- PyRandom self=(PyRandom)gself;
- return self.random_seed();
- }
-
- }
- dict.__setitem__("seed",new PyMethodDescr("seed",PyRandom.class,0,1,new exposed_seed(null,null)));
- class exposed_getstate extends PyBuiltinFunctionNarrow {
-
- private PyRandom self;
-
- public PyObject getSelf() {
- return self;
- }
-
- exposed_getstate(PyRandom self,PyBuiltinFunction.Info info) {
- super(info);
- this.self=self;
- }
-
- public PyBuiltinFunction makeBound(PyObject self) {
- return new exposed_getstate((PyRandom)self,info);
- }
-
- public PyObject __call__() {
- return self.random_getstate();
- }
-
- public PyObject inst_call(PyObject gself) {
- PyRandom self=(PyRandom)gself;
- return self.random_getstate();
- }
-
- }
- dict.__setitem__("getstate",new PyMethodDescr("getstate",PyRandom.class,0,0,new exposed_getstate(null,null)));
- class exposed_setstate extends PyBuiltinFunctionNarrow {
-
- private PyRandom self;
-
- public PyObject getSelf() {
- return self;
- }
-
- exposed_setstate(PyRandom self,PyBuiltinFunction.Info info) {
- super(info);
- this.self=self;
- }
-
- public PyBuiltinFunction makeBound(PyObject self) {
- return new exposed_setstate((PyRandom)self,info);
- }
-
- public PyObject __call__(PyObject arg0) {
- return self.random_setstate(arg0);
- }
-
- public PyObject inst_call(PyObject gself,PyObject arg0) {
- PyRandom self=(PyRandom)gself;
- return self.random_setstate(arg0);
- }
-
- }
- dict.__setitem__("setstate",new PyMethodDescr("setstate",PyRandom.class,1,1,new exposed_setstate(null,null)));
- class exposed_jumpahead extends PyBuiltinFunctionNarrow {
-
- private PyRandom self;
-
- public PyObject getSelf() {
- return self;
- }
-
- exposed_jumpahead(PyRandom self,PyBuiltinFunction.Info info) {
- super(info);
- this.self=self;
- }
-
- public PyBuiltinFunction makeBound(PyObject self) {
- return new exposed_jumpahead((PyRandom)self,info);
- }
-
- public PyObject __call__() {
- return self.random_jumpahead();
- }
-
- public PyObject inst_call(PyObject gself) {
- PyRandom self=(PyRandom)gself;
- return self.random_jumpahead();
- }
-
- }
- dict.__setitem__("jumpahead",new PyMethodDescr("jumpahead",PyRandom.class,0,0,new exposed_jumpahead(null,null)));
- class exposed_randrange extends PyBuiltinFunctionNarrow {
-
- private PyRandom self;
-
- public PyObject getSelf() {
- return self;
- }
-
- exposed_randrange(PyRandom self,PyBuiltinFunction.Info info) {
- super(info);
- this.self=self;
- }
-
- public PyBuiltinFunction makeBound(PyObject self) {
- return new exposed_randrange((PyRandom)self,info);
- }
-
- public PyObject __call__() {
- return self.random_randrange();
- }
-
- public PyObject inst_call(PyObject gself) {
- PyRandom self=(PyRandom)gself;
- return self.random_randrange();
- }
-
- }
- dict.__setitem__("randrange",new PyMethodDescr("randrange",PyRandom.class,0,0,new exposed_randrange(null,null)));
- class exposed___init__ extends PyBuiltinFunctionWide {
-
- private PyRandom self;
-
- public PyObject getSelf() {
- return self;
- }
-
- exposed___init__(PyRandom self,PyBuiltinFunction.Info info) {
- super(info);
- this.self=self;
- }
-
- public PyBuiltinFunction makeBound(PyObject self) {
- return new exposed___init__((PyRandom)self,info);
- }
-
- public PyObject inst_call(PyObject self,PyObject[]args) {
- return inst_call(self,args,Py.NoKeywords);
- }
-
- public PyObject __call__(PyObject[]args) {
- return __call__(args,Py.NoKeywords);
- }
-
- public PyObject __call__(PyObject[]args,String[]keywords) {
- self.random_init(args,keywords);
- return Py.None;
- }
-
- public PyObject inst_call(PyObject gself,PyObject[]args,String[]keywords) {
- PyRandom self=(PyRandom)gself;
- self.random_init(args,keywords);
- return Py.None;
- }
-
- }
- dict.__setitem__("__init__",new PyMethodDescr("__init__",PyRandom.class,-1,-1,new exposed___init__(null,null)));
- dict.__setitem__("__new__",new PyNewWrapper(PyRandom.class,"__new__",-1,-1) {
-
- public PyObject new_impl(boolean init,PyType subtype,PyObject[]args,String[]keywords) {
- PyRandom newobj;
- if (for_type==subtype) {
- newobj=new PyRandom();
- if (init)
- newobj.random_init(args,keywords);
- } else {
- newobj=new PyRandomDerived(subtype);
- }
- return newobj;
- }
-
- });
- }
- //~ END GENERATED REGION -- DO NOT EDIT SEE gexpose.py
-
- private static final PyType RANDOMTYPE = PyType.fromClass(PyRandom.class);
-
- public PyRandom() {
- this(RANDOMTYPE);
- }
-
- public PyRandom(PyType subType) {
- super(subType);
- }
-
- }
-
Deleted: trunk/website/Project/related.txt
===================================================================
--- trunk/website/Project/related.txt 2007-12-30 19:06:53 UTC (rev 3909)
+++ trunk/website/Project/related.txt 2007-12-30 19:34:40 UTC (rev 3910)
@@ -1,6 +0,0 @@
-* Python_ project
-* PyPy_ project
-
-.. _Python: http://www.python.org
-.. _PyPy: http://www.pypy.org
-
Modified: trunk/website/Project/userfaq.txt
===================================================================
--- trunk/website/Project/userfaq.txt 2007-12-30 19:06:53 UTC (rev 3909)
+++ trunk/website/Project/userfaq.txt 2007-12-30 19:34:40 UTC (rev 3910)
@@ -160,9 +160,8 @@
so dir(someJavaObject.__class__) would return a list of the method names
(although only for the direct class, not for any base classes).
-Why can't I execute a 'protected' or 'private' Java instance method or
-access a 'protected' or 'private' attribute in a Java package?
----------------------------------------------------------------------------------------------------------------------------
+Why can't I execute a 'protected' or 'private' Java instance method or access a 'protected' or 'private' attribute in a Java package?
+-------------------------------------------------------------------------------------------------------------------------------------
By default, as in Java, these methods are protected from external
access. Access to all Java fields and methods can be enabled with the
python.security.respectJavaAccessibility registry setting::
Modified: trunk/website/Project/userguide.txt
===================================================================
--- trunk/website/Project/userguide.txt 2007-12-30 19:06:53 UTC (rev 3909)
+++ trunk/website/Project/userguide.txt 2007-12-30 19:34:40 UTC (rev 3910)
@@ -617,8 +617,9 @@
Embedding Jython
----------------
-There are two options for embedding Jython in a Java
-application. You can make a real Java class out of a Python class, and then call it from your Java code, as previously described, or you can use the PythonInterpreter object
+There are two options for embedding Jython in a Java application. You can make
+a real Java class out of a Python class, and then call it from your Java code,
+as previously described, or you can use the PythonInterpreter object
Information on the PythonInterpreter can be found in the JavaDoc documentation for `org.python.util.PythonInterpreter`_.
@@ -629,9 +630,9 @@
import sys
print sys
- a=42
+ a = 42
print a
- x=2+2
+ x = 2 + 2
print "x:",x
@@ -639,30 +640,63 @@
The java code required to execute the python program:
::
+ import org.python.core.PyException;
+ import org.python.core.PyInteger;
+ import org.python.core.PyObject;
import org.python.util.PythonInterpreter;
- import org.python.core.*;
public class SimpleEmbedded {
- public static void main(String []args)
- throws PyException
- {
- PythonInterpreter interp =
- new PythonInterpreter();
- System.out.println("Hello, brave new world");
+ public static void main(String[] args) throws PyException {
+ PythonInterpreter interp = new PythonInterpreter();
interp.exec("import sys");
interp.exec("print sys");
-
interp.set("a", new PyInteger(42));
interp.exec("print a");
interp.exec("x = 2+2");
PyObject x = interp.get("x");
+ System.out.println("x: " + x);
+ }
+ }
+
+Using JSR 223
+=============
- System.out.println("x: "+x);
- System.out.println("Goodbye, cruel world");
+JSR 223, Scripting for the Java language, added the javax.script pacakge to
+Java 6. It allows multiple scripting languages to be used through the same API
+as long as the language provides a script engine. The `scripting project`_
+contains such an engine for Jython. It can be used to embed Jython in your
+application alongside many other languages that have script engines such as JRuby or Groovy.
+
+The usage of PythonInterpreter above translates to the following using JSR 223:
+::
+
+ import javax.script.ScriptEngine;
+ import javax.script.ScriptEngineManager;
+ import javax.script.ScriptException;
+
+ public class JSR223 {
+
+ public static void main(String[] args) throws ScriptException {
+ ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");
+ engine.eval("import sys");
+ engine.eval("print sys");
+ engine.put("a", 42);
+ engine.eval("print a");
+ engine.eval("x = 2 + 2");
+ Object x = engine.get("x");
+ System.out.println("x: " + x);
}
}
+To use JSR 223 with Jython, `download the engine`_ and add it to your classpath
+along with Jython. Then use code like the above to create and use an engine.
+One difference between embedding with JSR 223 and using PythonInterpreter
+directly is that the scripting engine manages its own PySystemState per thread
+so it can always set the classloader to the thread's context classloader. This
+means if you want to do anything Jython specific to PySystemState, like adding
+to sys.path or setting sys.stdin and sys.stdout, you should do it after
+creating the ScriptEngine.
---------------------------------------------------
Java Reload (experimental) simple Support - JReload
@@ -1406,3 +1440,5 @@
.. _Jython-users mailing list: http://lists.sourceforge.net/lists/listinfo/jython-users
.. _org.python.util.PythonInterpreter: http://www.jython.org/docs/javadoc/org/python/util/PythonInterpreter.html
.. _jythonc: jythonc.html
+.. _`scripting project`: https://scripting.dev.java.net/
+.. _`download the engine`: https://scripting.dev.java.net/servlets/ProjectDocumentList
Modified: trunk/website/left.nav
===================================================================
--- trunk/website/left.nav 2007-12-30 19:06:53 UTC (rev 3909)
+++ trunk/website/left.nav 2007-12-30 19:34:40 UTC (rev 3910)
@@ -2,24 +2,21 @@
menupageitem | Welcome | ../Project/index.html
menupageitem | License | ../Project/license.html
menupageitem | Installation | ../Project/installation.html
-menupageitem | Old Website | ../Jython21.html
menupageitem | FAQ | ../Project/userfaq.html
menupageitem | News | ../Project/news.html
menupageitem | History | ../Project/history.html
menupageitem | Download | ../Project/download.html
menupageitem | User Guide | ../Project/userguide.html
+menupageitem | Old Website | ../Jython21.html
#menupageitem | Books and Articles | ../Project/books_articles.html
#menupageitem | CPython comparison | ../Project/differences.html
-menupageitem | Related Projects | ../Project/related.html
section | Community
menupageitem | Wiki | http://wiki.python.org/jython/
menupageitem | Reporting Bugs | ../Project/bugs.html
menupageitem | Mailing Lists | http://sourceforge.net/mail/?group_id=12867
menupageitem | Developer FAQ | ../Project/devfaq.html
-menupageitem | Developer Guide | ../Project/devguide.html
+menupageitem | Developer Guide | http://wiki.python.org/jython/JythonDeveloperGuide
menupageitem | Jython Roadmap | ../Project/roadmap.html
-#menupageitem | JEP Index | ../jeps/jep-0000.html
-#menupageitem | To Do List | ../Project/todo.html
menupageitem | Contributors | ../Project/contributors.html
section |
raw | <div style="height:1em"></div>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|