You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(6) |
Nov
(8) |
Dec
(51) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(105) |
Feb
(93) |
Mar
(194) |
Apr
(145) |
May
(100) |
Jun
(111) |
Jul
(117) |
Aug
(126) |
Sep
(233) |
Oct
(138) |
Nov
(164) |
Dec
(109) |
2002 |
Jan
(216) |
Feb
(175) |
Mar
(216) |
Apr
(194) |
May
(157) |
Jun
(140) |
Jul
(158) |
Aug
(73) |
Sep
(105) |
Oct
(164) |
Nov
(104) |
Dec
(95) |
2003 |
Jan
(72) |
Feb
(69) |
Mar
(81) |
Apr
(151) |
May
(101) |
Jun
(139) |
Jul
(99) |
Aug
(118) |
Sep
(115) |
Oct
(151) |
Nov
(161) |
Dec
(102) |
2004 |
Jan
(120) |
Feb
(175) |
Mar
(106) |
Apr
(111) |
May
(54) |
Jun
(78) |
Jul
(76) |
Aug
(105) |
Sep
(94) |
Oct
(143) |
Nov
(75) |
Dec
(85) |
2005 |
Jan
(99) |
Feb
(77) |
Mar
(164) |
Apr
(97) |
May
(79) |
Jun
(57) |
Jul
(65) |
Aug
(102) |
Sep
(95) |
Oct
(129) |
Nov
(123) |
Dec
(52) |
2006 |
Jan
(48) |
Feb
(99) |
Mar
(90) |
Apr
(51) |
May
(81) |
Jun
(136) |
Jul
(56) |
Aug
(109) |
Sep
(50) |
Oct
(44) |
Nov
(74) |
Dec
(75) |
2007 |
Jan
(92) |
Feb
(137) |
Mar
(93) |
Apr
(79) |
May
(52) |
Jun
(74) |
Jul
(143) |
Aug
(175) |
Sep
(154) |
Oct
(137) |
Nov
(88) |
Dec
(90) |
2008 |
Jan
(58) |
Feb
(113) |
Mar
(167) |
Apr
(88) |
May
(105) |
Jun
(37) |
Jul
(87) |
Aug
(72) |
Sep
(56) |
Oct
(41) |
Nov
(102) |
Dec
(70) |
2009 |
Jan
(115) |
Feb
(113) |
Mar
(126) |
Apr
(58) |
May
(125) |
Jun
(45) |
Jul
(90) |
Aug
(125) |
Sep
(84) |
Oct
(61) |
Nov
(111) |
Dec
(61) |
2010 |
Jan
(85) |
Feb
(86) |
Mar
(130) |
Apr
(58) |
May
(57) |
Jun
(32) |
Jul
(25) |
Aug
(50) |
Sep
(41) |
Oct
(65) |
Nov
(63) |
Dec
(24) |
2011 |
Jan
(43) |
Feb
(31) |
Mar
(28) |
Apr
(68) |
May
(53) |
Jun
(42) |
Jul
(58) |
Aug
(26) |
Sep
(51) |
Oct
(76) |
Nov
(60) |
Dec
(9) |
2012 |
Jan
(16) |
Feb
(32) |
Mar
(32) |
Apr
(39) |
May
(16) |
Jun
(19) |
Jul
(3) |
Aug
(11) |
Sep
(35) |
Oct
(47) |
Nov
(28) |
Dec
(18) |
2013 |
Jan
(18) |
Feb
(36) |
Mar
(10) |
Apr
(7) |
May
(7) |
Jun
(27) |
Jul
(17) |
Aug
(35) |
Sep
(19) |
Oct
(31) |
Nov
(8) |
Dec
(22) |
2014 |
Jan
(5) |
Feb
(11) |
Mar
(18) |
Apr
(23) |
May
(26) |
Jun
(14) |
Jul
(18) |
Aug
(26) |
Sep
(20) |
Oct
(48) |
Nov
(13) |
Dec
(9) |
2015 |
Jan
(9) |
Feb
(15) |
Mar
(25) |
Apr
(10) |
May
(26) |
Jun
(6) |
Jul
(13) |
Aug
(5) |
Sep
(14) |
Oct
(36) |
Nov
(24) |
Dec
(18) |
2016 |
Jan
(24) |
Feb
(11) |
Mar
(1) |
Apr
(6) |
May
(7) |
Jun
(3) |
Jul
(9) |
Aug
(15) |
Sep
(22) |
Oct
(5) |
Nov
(5) |
Dec
(2) |
2017 |
Jan
(20) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(5) |
Jun
(7) |
Jul
(14) |
Aug
(9) |
Sep
(18) |
Oct
(2) |
Nov
(3) |
Dec
(3) |
2018 |
Jan
(7) |
Feb
(6) |
Mar
(1) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
(18) |
Sep
(8) |
Oct
(9) |
Nov
(4) |
Dec
(6) |
2019 |
Jan
(5) |
Feb
|
Mar
(2) |
Apr
(4) |
May
(6) |
Jun
(8) |
Jul
(11) |
Aug
(10) |
Sep
(6) |
Oct
|
Nov
(1) |
Dec
|
2020 |
Jan
(8) |
Feb
(3) |
Mar
(1) |
Apr
(4) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
(1) |
Oct
(5) |
Nov
(2) |
Dec
(1) |
2021 |
Jan
|
Feb
|
Mar
(5) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
(2) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(7) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
(5) |
Jul
(15) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
(1) |
Mar
|
Apr
(2) |
May
|
Jun
(5) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Robert W. B. <rb...@di...> - 2001-10-25 20:33:38
|
On Thu, 25 Oct 2001, Andres Corrada-Emmanuel wrote: > ... > I've gone further and confirmed that if my Foo.java code makes the > attribute public, everything works fine. This seems to contradict the > Java transparency claim for Jython also: I think setting python.respectJavaAccessibility to false convinces even the most reluctant to believe in transparency <g> -robert |
From: Robert W. B. <rb...@di...> - 2001-10-25 20:25:31
|
On Thu, 25 Oct 2001, Andres Corrada-Emmanuel wrote: > On Thu, 25 Oct 2001, Kevin Butler wrote: > > [CC's removed] > > Andres, > > You need to explicitly declare the 'outputTags' attribute as public: > > > > public String outputTags; > > > > Your existing declaration: > > > > > String outputTags; > > > > leaves it 'package-protected' ("friendly"), and subclasses could normally use it just fine, but because Jython attempts to access the attribute from its own package, the field is not visible. > > > > kb > > Okay. I got that working. But this brings me back to my original problem: > I have a Python class that subclasses a Java class in a package. How do I > tell Python that it can access that package's attributes? I was mistaken earlier about saying there's a difference between package private fields and methods. I confused myself into thinking protected attributes. Yes, package private attributes are inaccessible. I do not know of a way to "tell" jython that it can access them other than setting respectJavaAccessibility to false. > When I compile the Python class with jythonc I use the --package option > and can see that the .java file created does have the correct package > statement but I still cannot see the super's attributes. You mean just package private attributes and protected fields, right? You do have access to protected methods and everything public in the superclass. > Isn't that problematic? <opinion> Not really. If you are writing the package, you have the power to use jython-friendly permissions. If someone else wrote the package, chastise them for making users develop in the same package <g> You also have the choice to set respectJavaAccessibility to false. </opinion> -robert > Andres Corrada-Emmanuel > Senior Research Fellow > Center for Intelligent Information Retrieval > University of Massachusetts, Amherst |
From: Andres Corrada-E. <co...@ci...> - 2001-10-25 20:04:59
|
Hello, My problem has evolved to this thread. Let me recapitulate my intent: To create a Java class using Python code. The Python class subclasses from a class in some package "edu.umass.cs.ciir.metamorph". I compile the Python class to a .class file using jythonc with the package switch. The resultant .java file has the correct package declaration: package edu.umass.cs.ciir.metamorph; at the top of the file. My Python class tries to access a package-accesible super attribute but fails. If I make that attribute public it succeeds. This is unsatisfactory. I'm trying to use someone elses code and I cannot change the attribute properties. Can I still use Jython or do I need to abandon this line of approach and resign myself to having to program in Java directly? Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst |
From: Andres Corrada-E. <co...@ci...> - 2001-10-25 18:35:12
|
On Thu, 25 Oct 2001, Kevin Butler wrote: > [CC's removed] > > Andres, > > You need to explicitly declare the 'outputTags' attribute as public: > > public String outputTags; > > Your existing declaration: > > > String outputTags; > > leaves it 'package-protected' ("friendly"), and subclasses could normally use it just fine, but because Jython attempts to access the attribute from its own package, the field is not visible. > > kb > Okay. I got that working. But this brings me back to my original problem: I have a Python class that subclasses a Java class in a package. How do I tell Python that it can access that package's attributes? When I compile the Python class with jythonc I use the --package option and can see that the .java file created does have the correct package statement but I still cannot see the super's attributes. Isn't that problematic? Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst |
From: Andres Corrada-E. <co...@ci...> - 2001-10-25 18:28:52
|
Hi Robert, The files I'm using can be seen at: http://aspn.activestate.com/ASPN/Mail/Message/Jython-users/819819 I've gone further and confirmed that if my Foo.java code makes the attribute public, everything works fine. This seems to contradict the Java transparency claim for Jython also: -I can write Java classes that use Foo.java and they can access Foo's attributes without having to make those attributes public. -A python class can only access explicitly public attributes. On Thu, 25 Oct 2001, Robert W. Bill wrote: > > Is this the random postings from a while back, or something new > I'm not seeing yet? I actually have a few minutes to take a good > look this afternoon rather than the guesses sent so for :) If you > could point me to these simple files it would help. > > Tnx, > Robert The problem with calling java.util.Random's initializer was solved by a posting made by Finn. This thread is about my next step: getting a Python class to access package variables. To simplify the problem, I have come up with the simple files shown in the URL above. Thanks for your help on this. Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst |
From: Andres Corrada-E. <co...@ci...> - 2001-10-25 17:52:46
|
On Thu, 25 Oct 2001, Robert W. Bill wrote: > Hi Andres, > > . > . > . > IIRC Jython's indirection causes the actual call in this case to originate > from the org.python.core package. Methods go through the proxy to act like > the real package/subclass, but fields do not. In other words, your > stringArray needs to be public, or you need to write an intermediate/shell > java class that exposes this field (e.g. a get method). > Hi Robert, I've managed to recreate the problem with simple files that I sent in a previous posting. It seems that the problem is worse, one cannot access super class attributes even if one just uses Jython. This seems to contradict the claim that Jython allows you to use Java classes transparently so I think I must be missing the correct syntax to do the work. Andres Corrada-Emmanuel |
From: Andres Corrada-E. <co...@ci...> - 2001-10-25 17:45:38
|
Hello, I have simplified my problem of accessing super class attributes to the following simple files-- Java super class: public class Foo { String outputTags; public Foo() { outputTags = new String("This is the Foo string!"); } } Python class that subclasses this Foo java class: import Foo class Bar(Foo): def __init__( self ): "Do nothing since jythonc will call Foo's constructor." pass def testAttributeCall( self ): "@sig public java.lang.String testAttributeCall()" return self.outputTags Java file to test jythonc's creation of Bar.class: import Bar; class TestAttribute { public static void main(String args[]){ Bar myBar = new Bar(); System.out.println( myBar.testAttributeCall() ); } } This fails with: AttributeError: instance of 'Bar' has no attribute 'outputTags'. The problem is also present if the Bar.py file is used (with an added Foo.__init__(self) call) from within Jython. So the question remains, how does one call super class attributes to avoid the AttributeError? Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst |
From: Robert W. B. <rb...@di...> - 2001-10-25 17:34:46
|
Hi Andres, On Thu, 25 Oct 2001, Andres Corrada-Emmanuel wrote: > On Wed, 24 Oct 2001, Robert W. Bill wrote: > > Is the stringArrayInitializedInSuperMethodCalledBefore a protected field? > > or public? > > > > Just curious because field access does not go through the proxy making > > protected fields == private. > > stringArrayInitializedInSuperMethodCalledBefore is defined as "package > private". I have run jythonc with the --package option set to the super's > package and confirmed that the package statement is correct in the > generated .java file. The error still occurs nonetheless: I cannot access > super class attributes in my Python code (which in turn is converted into > a .class file). IIRC Jython's indirection causes the actual call in this case to originate from the org.python.core package. Methods go through the proxy to act like the real package/subclass, but fields do not. In other words, your stringArray needs to be public, or you need to write an intermediate/shell java class that exposes this field (e.g. a get method). -Robert |
From: Andres Corrada-E. <co...@to...> - 2001-10-25 14:14:01
|
On Wed, 24 Oct 2001, Robert W. Bill wrote: > > Is the stringArrayInitializedInSuperMethodCalledBefore a protected field? > or public? > > Just curious because field access does not go through the proxy making > protected fields == private. > stringArrayInitializedInSuperMethodCalledBefore is defined as "package private". I have run jythonc with the --package option set to the super's package and confirmed that the package statement is correct in the generated .java file. The error still occurs nonetheless: I cannot access super class attributes in my Python code (which in turn is converted into a .class file). |
From: Andres Corrada-E. <co...@ci...> - 2001-10-24 19:02:42
|
Hi, I'm building a Java class from Python code using Jython (jythonc properly speaking). My Python code refences an attribute that exists in the Java super class, something like this: class MyClass( JavaSuperClass ): . . . def foo( self ): aStringArray = self.stringArrayInitializedInSuperMethodCalledBefore This fails with an attribute not found error. The traceback shows that the jythonc derived class is trying to find the attribute in the Python side of MyClass, while the attribute is really in the super class in the Java side. What is the proper syntax for calling a super's attribute in Python code that will be turned into a Java class? Thank you. Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst |
From: Andres Corrada-E. <co...@ci...> - 2001-10-24 13:59:19
|
Hi Finn, Thank you for helping me out on this problem. I'll post my modified scripts when I get them to work so others can avoid my mistakes. Andres Corrada-Emmanuel |
From: O'Brien-Strain, E. <eo...@ex...> - 2001-10-23 19:43:45
|
Possibly you need to put the jar file for some XML parser on your classpath. You can get the xerces parser from: http://xml.apache.org/xerces-j/ __ Eamonn O'Brien-Strain HP Labs eo...@hp... -----Original Message----- From: Michael Chermside [mailto:mc...@de...] Sent: Tuesday, October 23, 2001 7:58 AM To: jyt...@li... Subject: [Jython-users] jython with xml Hoping someone can help: I wrote a quick prototype in cpython for my project; but now I'd like to compile with jython and run under java. My program uses some things from the xml package. At first, I was worried that it wouldn't be possible (no parser), but as I was reading xml.sax.__init__.py, I saw that it has special casing for the java environment. 1) Can I run something using the xml parser under jython? 2) If so, then what am I doing wrong? I have been setting sys.path to include my python 'libs' directory, then importing my package. I get an exception: File "C:\Applications\Python21\lib\xml\sax\__init__.py", line 88, in make_parser SAXReaderNotAvailable: No parsers found This looks bad, but the special-case code must be there for some reason. Anyone able to help? -- Michael Chermside _______________________________________________ Jython-users mailing list Jyt...@li... https://lists.sourceforge.net/lists/listinfo/jython-users |
From: <bc...@wo...> - 2001-10-23 19:33:55
|
[Max Muller] >Hi, > So I've got the PythonInterpreter running inside my Java app >(thanks to everyone for the pointers to PyServlet example) and I >successfully get a Proxied class object from this bit of code that >looks something like: > > interpreter().execfile(testFile.getAbsolutePath()); > > PyObject cls = interpreter().get("Test"); > > Object o = cls.__tojava__(Class.class); > > Class testClass = (Class)o; I don't think we ever tested this when the code was create with exec/execfile. I believe it works when the python code is placed in a module. The proxy tries to import the module that the code was compiled from. Do you really need to call the java Constructor directly? Normally it it a lot easier to simple call the python class: PyObject instance = cls.__call__(Py.java2py(aWOContext)); regards, finn |
From: <bc...@wo...> - 2001-10-23 19:10:32
|
[Andres Corrada-Emmanuel] >Apparently the answer is no if you plan to turn that python class back >into a java class. Right. >Is this a bug or am I not getting how to turn python >classes into java classes? > >I have the following python class that subclasses from java.util.Random. >It's a modification of the rand.py code shown in the jython website: > >rand.py: > >from java.util import Random > >class rand(Random): > def __init__( self ): > "@sig public rand()" > Random.__init__( self ) > > def nextDouble( self ): > return Random.nextDouble( self ) > >This is turned into a java class with jythonc. It is tested with this >java file: > >TestRand.java: > >import rand; > >class TestRand >{ > public static void main(String args[]){ > rand firstRand = new rand(); > System.out.println( firstRand.nextDouble() ); > } >} > >Executing this java file leads to an "instance already instantiated" >error. If this sounds familiar to you maybe you've read my previous >two emails to the list on this problem. Nobody seems to care :-( Thats wrong; I care, but I am too busy to spend much time on it at the moment. >The code works if you take Random.__init__(self) out of rand.py. But >this means you cannot call the super class constructor within your own >init. This sucks! Right, and there is *no* way we can fix that. Remember that rand is a true subclass of Random and there is no way we can execute any jython (or java) code in the constructor before calling super(). Looking at the ctor in rand.java the problem is obvious: public rand() { super(); __initProxy__(new Object[] {}); } The call to __initProxy__ will eventually call rand.__init__ but then the Random ctor have been called already. >It must be something I'm doing wrong because the website >explicitly mentions that you CAN call the super class constructor. Yes, but that is when the python instance is created before the proxyinstance. When creating the class from java, the proxyinstance is create first and then we have to accept the arguments pass from the java side. >Please, please, please help me out of my quagmire. I'm dying to use Python >and if this doesn't work for me I'll be condemned to writing Java code. Try to change rand.py to (without any @sig for the ctor): from java.util import Random class rand(Random): def __init__( self): pass def nextDouble( self ): return Random.nextDouble( self ) That will create the two java ctors: public rand(long arg0) { super(arg0); __initProxy__(new Object[] {Py.newInteger(arg0)}); } public rand() { super(); __initProxy__(new Object[] {}); } and you can then create an instance of "new rand(42)" from the java test program. You still can't call the Random.__init__ from python. I hope this helps. regards, finn |
From: Michael C. <mc...@de...> - 2001-10-23 14:56:38
|
Hoping someone can help: I wrote a quick prototype in cpython for my project; but now I'd like to compile with jython and run under java. My program uses some things from the xml package. At first, I was worried that it wouldn't be possible (no parser), but as I was reading xml.sax.__init__.py, I saw that it has special casing for the java environment. 1) Can I run something using the xml parser under jython? 2) If so, then what am I doing wrong? I have been setting sys.path to include my python 'libs' directory, then importing my package. I get an exception: File "C:\Applications\Python21\lib\xml\sax\__init__.py", line 88, in make_parser SAXReaderNotAvailable: No parsers found This looks bad, but the special-case code must be there for some reason. Anyone able to help? -- Michael Chermside |
From: Kevin M. <kev...@er...> - 2001-10-23 14:26:59
|
Hi, use jythonc -p com.seth.rohit.myPackage A.py The package can then be found under the 'jpywork' directory /Kevin On Tue, 23 Oct 2001, rohit seth wrote: > Hi, > I am using jythonc to convert A.py to A.java, A.class. > I want my corresponding A.class file to be placed > under some package. How can I do this? That is how can > I structure my python scripts so that after > compilation, the corrsponding class files produced are > part of some package(just like java packages) > This is required for importing the corresponding class > files in my java programs. > Regards, > Rohit > > __________________________________________________ > Do You Yahoo!? > Make a great connection at Yahoo! Personals. > http://personals.yahoo.com > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > _________________________________________________ Name/Title : Kevin McNamee, Software Consultant Phone : +46 13 32 1165 |
From: rohit s. <ro2...@ya...> - 2001-10-23 14:13:08
|
Hi, I am using jythonc to convert A.py to A.java, A.class. I want my corresponding A.class file to be placed under some package. How can I do this? That is how can I structure my python scripts so that after compilation, the corrsponding class files produced are part of some package(just like java packages) This is required for importing the corresponding class files in my java programs. Regards, Rohit __________________________________________________ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com |
From: Andres Corrada-E. <co...@ci...> - 2001-10-23 13:32:41
|
Apparently the answer is no if you plan to turn that python class back into a java class. Is this a bug or am I not getting how to turn python classes into java classes? I have the following python class that subclasses from java.util.Random. It's a modification of the rand.py code shown in the jython website: rand.py: from java.util import Random class rand(Random): def __init__( self ): "@sig public rand()" Random.__init__( self ) def nextDouble( self ): return Random.nextDouble( self ) This is turned into a java class with jythonc. It is tested with this java file: TestRand.java: import rand; class TestRand { public static void main(String args[]){ rand firstRand = new rand(); System.out.println( firstRand.nextDouble() ); } } Executing this java file leads to an "instance already instantiated" error. If this sounds familiar to you maybe you've read my previous two emails to the list on this problem. Nobody seems to care :-( The code works if you take Random.__init__(self) out of rand.py. But this means you cannot call the super class constructor within your own init. This sucks! It must be something I'm doing wrong because the website explicitly mentions that you CAN call the super class constructor. Please, please, please help me out of my quagmire. I'm dying to use Python and if this doesn't work for me I'll be condemned to writing Java code. Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst |
From: <ti...@su...> - 2001-10-23 05:36:28
|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Consolidate all your debt into ONE, EASY monthly payment! We will help you: *Eliminate interest charges *Waive late fee charges *Improve your credit rating And best of all, lower your monthly payments by 40%-60% and KEEP MORE CASH IN YOUR POCKET! Take just 1 minute to complete our Credit Card Consolidation Form and one of our experienced professional consultants will contact you! http://thedebtconsolidation.com There is no obligation and our service is fast and free! All information is kept strictly confidential. **************************************************************** Since you have received this message you have either responded to one of our offers in the past or your address has been registered with us. If you wish to be removed please reply: mailto:swe...@ya...?subject=remove **************************************************************** ********** |
From: Ihab A.B. A. <ih...@ah...> - 2001-10-22 22:25:17
|
Hey Robert & everyone, My sincerest apologies. I was using -- /opt/jython-2.1a1/ when I should have been using -- /opt/java/jython-2.1a1/ because, um, well -- the latter, not the former, is where Jython is installed on my system!!!! So I fixed my paths and things work now. :) That said, I think I learned a lot from this experience about setting up the Jython environment that I wouldn't have otherwise, so all is well. Many thanks for all the help. Regards & peace, Ihab -- Ihab A.B. Awad <ih...@ah...> Center for Computational Genomics and Bioinformatics, University of Minnesota. http://www.cbc.umn.edu/~ihab/ |
From: <Mat...@i2...> - 2001-10-22 19:49:46
|
Look at Demo/swing/Console.py. It runs each jython command in its own thread, and allows the user to kill that thread by hitting ESC Matt On 10/22/2001 01:44:33 PM jython-users-admin wrote: > > somehow tell the interpreter to break out of the current command that > it is processing and return to the command line so I can preserve as > much application state as possible. Any suggestions? |
From: Max M. <max...@ma...> - 2001-10-22 19:36:02
|
Hi, So I've got the PythonInterpreter running inside my Java app (thanks to everyone for the pointers to PyServlet example) and I successfully get a Proxied class object from this bit of code that looks something like: interpreter().execfile(testFile.getAbsolutePath()); PyObject cls = interpreter().get("Test"); Object o = cls.__tojava__(Class.class); Class testClass = (Class)o; This testClass is the class object for the Test class file read in from this Test.py: from com.webobjects import appserver class Test(appserver.WOComponent): def testName(self): "@sig public String testName()" return "Hello World" So the catch is that a subclass of WOComponent must be created with a one argument constructor, soemthing that would normally look like Test t = new Test(aWOContext). So from the created Class object I grab the correct constructor and then attempt to create the object at which point I get the following exception: code: wocomponent = constructor.newInstance(new Object[] { aWOContext }); Exception: Traceback (innermost last): (no code object) at line 0 ImportError: no module named main Anyone know offhand? Can you create a proxied object via a constructor off of the Class object or have I somehow bungled my jython environment? Thanks for any help. Regards, Max |
From: Robert W. B. <rb...@di...> - 2001-10-22 19:07:06
|
On Mon, 22 Oct 2001, Ihab A.B. Awad wrote: > Hi all, > > Thanks Robert Bill & Jim Adrig for the tips.... > > > Yes, os requires the javaos module, and you get the ImportError when that > > module cannot be Located. Fix= make sure module is found. > > I've been trying, in every manner possible! Here's my code -- > > rootPath = servletContext.getRealPath("/"); > if (!rootPath.endsWith(File.separator)) rootPath += File.separator; > > Properties p = getInitParametersAsProperties(); > p.put( > "python.cachedir", > servletContext.getAttribute("javax.servlet.context.tempdir").toString()); Maybe try: p.put("python.home", "some/path/that/contains/jython's/Lib/dir") Finding the cachedir will not help jython locate its modules, but finding the correct python.home will. > PythonInterpreter.initialize(System.getProperties(), p, new String[0]); > > PySystemState pySys = Py.getSystemState(); > pySys.add_classdir(rootPath + "WEB-INF" + File.separator + "classes"); > pySys.add_extdir(rootPath + "WEB-INF" + File.separator + "lib"); > pySys.path.append(new PyString(servletContext.getAttribute("python.home") + > File.separator + "Lib")); Maybe try printing python.home to make sure it isn't empty. Actually, printing python.home and sys.path is a good test. > pySys.path.append(new PyString(rootPath + "WEB-INF" + File.separator + > "py")); Are the jython modules in WEB-INF/py/? If javaos.py is there, I'm stumped :( > pythonInterpreter = new PythonInterpreter(null, pySys); > > I think, based on looking at PyServlet.java, that this should get all my > bases covered. Print python.path and python.home to make sure they are correct. That's the easiest way to make sure bases are covered. I would not trust everything is covered until I got a confirmation that the sys.path actually did include the directory that javaos.py lives in. Best of luck. -robert > However, I still get -- > > import os > dir(os) > > Traceback (innermost last): File "", line 10, in ? ImportError: no > module named javaos > > import os > print os.listdir('/home/ihab') > > Traceback (innermost last): File "", line 2, in ? AttributeError: class > 'org.python.modules.os' has no attribute 'listdir' > > This is all very confusing. Any help appreciated from anyone. Peace, |
From: Ihab A.B. A. <ih...@ah...> - 2001-10-22 18:39:51
|
Hi all, More re this issue. I finally decided to use PyServlet verbatim, as a baseline test case. Here is the relevant part of my "web.xml" file -- <servlet> <servlet-name>PyServlet</servlet-name> <servlet-class>org.python.util.PyServlet</servlet-class> <init-param> <param-name>python.home</param-name> <param-value>/opt/java/jython-2.1a1</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>PyServlet</servlet-name> <url-pattern>*.py</url-pattern> </servlet-mapping> and here is a servlet in Jython -- from javax.servlet.http import HttpServlet import os class test(HttpServlet): def doGet(self, req, res): res.setContentType("text/html"); out = res.getOutputStream() print >>out, "Hello World, how are we?" print >>out, dir(os) print >>out, os.listdir('/home/ihab') out.close() return Now, when I invoke this, I get the following -- Hello World, how are we? ['__depends__', 'classDictInit'] A Servlet Exception Has Occurred Traceback (innermost last): File "/home/ihab/www-docs/logs/../bin/../webapps/omtdb/ ... edu/umn/genomics/omtdb/test.py", line 24, in doGet AttributeError: class 'org.python.modules.os' has no attribute 'listdir' so notice that dir(os) does not show any of the symbols that I would expect to find and, of course, invoking os.listdir() raises an exception. Thanks & peace, Ihab -- Ihab A.B. Awad <ih...@ah...> Center for Computational Genomics and Bioinformatics, University of Minnesota. http://www.cbc.umn.edu/~ihab/ |
From: Robert W. B. <rb...@di...> - 2001-10-22 18:39:23
|
Hello Hubert, On Mon, 22 Oct 2001, yoshizak wrote: > Hi there, > I was looking at the error message and the problem with PyProxy lead me > to think I should put the jython.jar into the class path (I believe I > saw another e-mail in the user archives that said something about this) Yes, jython.jar is needed. Using jythonc without the --deep or --all options compiles your script to java bytecode, but running that script still requires the Jython classes found in jython.jar. There are times when using jythonc's --deep and --all options are beneficial because they allow you to include required jython files in a single jar. > don't exactly know why I needed to do this, since I had presumed that > this was done by default Java has no default or intuitive knowledge of Jython, so you must be explicit about these things when running commands that start with "java ". > but when I ran my code sample with > java -classpath <some directory tree>/jython-2.0/jython.jar:. tryJythonMain > it finally seemed to run. (Yeah! Finally! :) Excellent. > Question is, why did I need to do this? I mean, I'm sure not 'everyone' > actually specifies the jar file when running their programs. The classes in jython.jar are always needed. Yes, 'everyone' doesn't always specify the jython.jar file on the command line. Some have explicitly added it to their classpath by some other means or they have used jythonc's --deep or --all option. If you use --deep/--all, the files from jython.jar are included in the output jar; but in the end, the files in the jython.jar file are always needed. > Do I really > need to specify the jar file in the classpath (or CLASSPATH)? The required classes in jython.jar must get stuck in the classpath one way or another. Cheers, Robert |