Josh Juneau | 1 Feb 14:15
Picon

Jython Monthly - Issue #38 - January 2010

The Jython Monthly Newsletter for January 2010 is now available.  The Jython Podcast will be made available on February 2nd.



Enjoy!
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
john.m.baker | 1 Feb 14:55
Favicon

Jython dictionary implementation

Hello,

Im making a call to a Python function that returns a dictionary (string -> dictionary), i.e.

a= {}

a[blah]= {active: True }

The Java code seems a bit odd.  Heres the call to return the dict a:

         Map<PyObject,PyObject> status = (Map<PyObject,PyObject>)f.__call__(params);

And then I can iterate through the keys:

         Iterator i = status.keySet().iterator();

         while (i.hasNext())

         {

            String key = (String)i.next();

            System.out.println("K "+key+" "+key.getClass());

I would expect K to be PyObject, but its String.  I would expect to write the Iterator as:

         Iterator<PyObject> i = status.keySet().iterator();

         while (i.hasNext())

         {

            PyObject key = (PyObject)i.next();

So, whats Jython doing as its a little confusing!


John

--

John Baker,

JEE Architect, London Web Technology.



This e-mail (including any attachments) is confidential, may contain
proprietary or privileged information and is intended for the named
recipient(s) only. Unintended recipients are prohibited from taking action
on the basis of information in this e-mail and must delete all copies.
Nomura will not accept responsibility or liability for the accuracy or
completeness of, or the presence of any virus or disabling code in, this
e-mail. If verification is sought please request a hard copy. Any reference
to the terms of executed transactions should be treated as preliminary only
and subject to formal written confirmation by Nomura. Nomura reserves the
right to monitor e-mail communications through its networks (in accordance
with applicable laws). No confidentiality or privilege is waived or lost by
Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is
a reference to any entity in the Nomura Holdings, Inc. group. Please read
our Electronic Communications Legal Notice which forms part of this e-mail:
http://www.Nomura.com/email_disclaimer.htm
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Jeff Emanuel | 1 Feb 17:41
Favicon

Re: Jython dictionary implementation


The Iterator returned by the Set returned by keySet() calls
toJava on the PyObject in Iterator.next().

* PyMapSet serves as a wrapper around Set Objects returned by the 
java.util.Map interface of
* PyDictionary. entrySet, values and keySet methods return this type for 
the java.util.Map
* implementation. This class is necessary as a wrapper to convert 
PyObjects to java Objects for
* methods that return values, and convert Objects to PyObjects for 
methods that take values. The
* translation is necessary to provide java access to jython dictionary 
objects. This wrapper also
* provides the expected backing functionality such that changes to the 
wrapper set or reflected in
* PyDictionary.

To get the unconverted PyObjects, you can call __iter__().

john.m.baker <at> nomura.com wrote:
>
> Hello,
>
> I’m making a call to a Python function that returns a dictionary 
> (string -> dictionary), i.e.
>
> a= {}
>
> a[‘blah’]= { ‘active’: True }
>
> The Java code seems a bit odd. Here’s the call to return the dict a:
>
> Map<PyObject,PyObject> status = 
> (Map<PyObject,PyObject>)f.__call__(params);
>
> And then I can iterate through the keys:
>
> Iterator i = status.keySet().iterator();
>
> while (i.hasNext())
>
> {
>
> String key = (String)i.next();
>
> System.out.println("K "+key+" "+key.getClass());
>
> I would expect K to be PyObject, but it’s String. I would expect to 
> write the Iterator as:
>
> Iterator<PyObject> i = status.keySet().iterator();
>
> while (i.hasNext())
>
> {
>
> PyObject key = (PyObject)i.next();
>
> So, what’s Jython doing as it’s a little confusing!
>
>
> John
>
> -- 
>
> John Baker,
>
> JEE Architect, London Web Technology.
>
>
>
> This e-mail (including any attachments) is confidential, may contain
> proprietary or privileged information and is intended for the named
> recipient(s) only. Unintended recipients are prohibited from taking 
> action
> on the basis of information in this e-mail and must delete all copies.
> Nomura will not accept responsibility or liability for the accuracy or
> completeness of, or the presence of any virus or disabling code in, this
> e-mail. If verification is sought please request a hard copy. Any 
> reference
> to the terms of executed transactions should be treated as preliminary 
> only
> and subject to formal written confirmation by Nomura. Nomura reserves the
> right to monitor e-mail communications through its networks (in 
> accordance
> with applicable laws). No confidentiality or privilege is waived or 
> lost by
> Nomura by any mistransmission of this e-mail. Any reference to 
> "Nomura" is
> a reference to any entity in the Nomura Holdings, Inc. group. Please read
> our Electronic Communications Legal Notice which forms part of this 
> e-mail:
> http://www.Nomura.com/email_disclaimer.htm
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> ------------------------------------------------------------------------
>
> _______________________________________________
> Jython-users mailing list
> Jython-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jython-users
>   

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
john.m.baker | 1 Feb 18:03
Favicon

Re: Jython dictionary implementation

Great write up - thanks.

> -----Original Message-----
> From: Jeff Emanuel [mailto:jemanuel <at> frii.com]
> Sent: 01 February 2010 16:42
> To: Baker, John (IT/UK)
> Cc: jython-users <at> lists.sourceforge.net
> Subject: Re: [Jython-users] Jython dictionary implementation
> 
> 
> The Iterator returned by the Set returned by keySet() calls
> toJava on the PyObject in Iterator.next().
> 
> * PyMapSet serves as a wrapper around Set Objects returned by the
> java.util.Map interface of
> * PyDictionary. entrySet, values and keySet methods return this type
> for
> the java.util.Map
> * implementation. This class is necessary as a wrapper to convert
> PyObjects to java Objects for
> * methods that return values, and convert Objects to PyObjects for
> methods that take values. The
> * translation is necessary to provide java access to jython dictionary
> objects. This wrapper also
> * provides the expected backing functionality such that changes to the
> wrapper set or reflected in
> * PyDictionary.
> 
> 
> To get the unconverted PyObjects, you can call __iter__().
> 
> john.m.baker <at> nomura.com wrote:
> >
> > Hello,
> >
> > I'm making a call to a Python function that returns a dictionary
> > (string -> dictionary), i.e.
> >
> > a= {}
> >
> > a['blah']= { 'active': True }
> >
> > The Java code seems a bit odd. Here's the call to return the dict a:
> >
> > Map<PyObject,PyObject> status =
> > (Map<PyObject,PyObject>)f.__call__(params);
> >
> > And then I can iterate through the keys:
> >
> > Iterator i = status.keySet().iterator();
> >
> > while (i.hasNext())
> >
> > {
> >
> > String key = (String)i.next();
> >
> > System.out.println("K "+key+" "+key.getClass());
> >
> > I would expect K to be PyObject, but it's String. I would expect to
> > write the Iterator as:
> >
> > Iterator<PyObject> i = status.keySet().iterator();
> >
> > while (i.hasNext())
> >
> > {
> >
> > PyObject key = (PyObject)i.next();
> >
> > So, what's Jython doing as it's a little confusing!
> >
> >
> > John
> >
> > --
> >
> > John Baker,
> >
> > JEE Architect, London Web Technology.
> >
> >
> >
> > This e-mail (including any attachments) is confidential, may contain
> > proprietary or privileged information and is intended for the named
> > recipient(s) only. Unintended recipients are prohibited from taking
> > action
> > on the basis of information in this e-mail and must delete all
copies.
> > Nomura will not accept responsibility or liability for the accuracy
> or
> > completeness of, or the presence of any virus or disabling code in,
> this
> > e-mail. If verification is sought please request a hard copy. Any
> > reference
> > to the terms of executed transactions should be treated as
> preliminary
> > only
> > and subject to formal written confirmation by Nomura. Nomura
reserves
> the
> > right to monitor e-mail communications through its networks (in
> > accordance
> > with applicable laws). No confidentiality or privilege is waived or
> > lost by
> > Nomura by any mistransmission of this e-mail. Any reference to
> > "Nomura" is
> > a reference to any entity in the Nomura Holdings, Inc. group. Please
> read
> > our Electronic Communications Legal Notice which forms part of this
> > e-mail:
> > http://www.Nomura.com/email_disclaimer.htm
> >
---------------------------------------------------------------------
> ---
> >
> >
---------------------------------------------------------------------
> ---------
> > The Planet: dedicated and managed hosting, cloud storage, colocation
> > Stay online with enterprise data centers and the best network in the
> business
> > Choose flexible plans and management services without long-term
> contracts
> > Personal 24x7 support from experience hosting pros just a phone call
> away.
> > http://p.sf.net/sfu/theplanet-com
> >
---------------------------------------------------------------------
> ---
> >
> > _______________________________________________
> > Jython-users mailing list
> > Jython-users <at> lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/jython-users
> >

This e-mail (including any attachments) is confidential, may contain
proprietary or privileged information and is intended for the named
recipient(s) only. Unintended recipients are prohibited from taking action
on the basis of information in this e-mail and must delete all copies.
Nomura will not accept responsibility or liability for the accuracy or
completeness of, or the presence of any virus or disabling code in, this
e-mail. If verification is sought please request a hard copy. Any reference
to the terms of executed transactions should be treated as preliminary only
and subject to formal written confirmation by Nomura. Nomura reserves the
right to monitor e-mail communications through its networks (in accordance
with applicable laws). No confidentiality or privilege is waived or lost by
Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is
a reference to any entity in the Nomura Holdings, Inc. group. Please read
our Electronic Communications Legal Notice which forms part of this e-mail:
http://www.Nomura.com/email_disclaimer.htm

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
Josh Juneau | 2 Feb 01:15
Picon

"The Definitive Guide to Jython: Python for the Java Platform" Has Been Published

The Definitive Guide to Jython: Python for the Java Platform has been published by Apress.  Authors include Jim Baker, Victor Ng, Leo Soto, Frank Wierzbicki, and myself.  The book can be found on the Apress website at:  http://apress.com/book/view/9781430225270


You can find the table of contents along with chapter drafts on the open source website at http://jythonbook.com at this time.  I am in currently in the process of converting all of the final drafts from Word to restructured text and then I will make them available on the open source site as well.

I want to thank all of the authors for the great work they have done.  I also want to thank everyone at Apress for helping us put this book together and for publishing it.  Another big thanks goes to our technical reviewers for all of the time they have put into this.  Last, but certainly not least, a big thanks goes to the community for helping us make this book a great resource!

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Sangeetha CSE | 3 Feb 07:34
Picon

Problems in running applet

Hello

I am having problems in running the Jython applet using the "jythonc" command.
Help needed. Please

Sangeetha

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
Sharon Lucas | 3 Feb 23:16
Picon
Favicon

Jython 2.5.1: "SystemError: Automatic proxy initialization should only occur on proxy classes"


Hi, we have a Java application that uses Jython and works fine with Jython 2.1.  I'm now porting it to use Jython 2.5.1.  However, I'm getting the following error using Jython 2.5.1:

  SystemError: Automatic proxy initialization should only occur on proxy classes

I see this error after calling copy.copy or copy.deepcopy() to copy a Java type variable (such as one of type java.util.ArrayList for example).  The copy completes without any errors but as soon as the copied variable is accessed in any fashion, this SystemError occurs.  Here's a simple example of this problem after copy.copy() is used to copy a java.util.ArrayList instance, and then the copied variable is accessed.  This example works fine using Jython 2.1.  

C:\jython2.5.1>jython
Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_13
Type "help", "copyright", "credits" or "license" for more information.
>>> from java.util import ArrayList
>>> gList = ArrayList()
>>> gList
[]
>>> import copy
>>> copyList = copy.copy(gList)
>>> copyList
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
SystemError: Automatic proxy initialization should only occur on proxy classes
>>> globals()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
SystemError: Automatic proxy initialization should only occur on proxy classes
>>>

Note this problem occurs with some other Java classes as well, including some custom  classes we use, not just a Java list.

Does anyone know why this problem occurs with Jython 2.5.1?  Is it a bug in Jython 2.5.1?  Or, if it's supposed to work this way in Jython 2.5.1, does anyone have suggestions for how I can avoid this problem?  It seems to me to be a very "bad" thing as globals() also then fails with this error.  Any suggestions are very appreciated.   Thanks.

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   lucass <at> us.ibm.com
(512) 286-7313 or Tieline 363-7313
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
stephanos | 4 Feb 20:59
Picon

Quick question: jythonc via Maven?


Is there any way to download+call jythonc via maven (e.g. antrun etc.) (just
like rhino, groovy, ruby and so on)? I only found the runtime environment.

PS: Manually downloading it is no option in my case.
--

-- 
View this message in context: http://old.nabble.com/Quick-question%3A-jythonc-via-Maven--tp27458817p27458817.html
Sent from the jython-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
stephanos | 4 Feb 21:01
Picon

Re: Quick question: jythonc via Maven?


By the way - it's for a good cause:  http://codingkata.org/ codingkata.org . 
A site where you can solve various programming problems with 'any' JVM
language 
(the 'any' part is why I asked this question - Jython would be a great
addition to the site!).

stephanos wrote:
> 
> Is there any way to download+call jythonc via maven (e.g. antrun etc.)
> (just like rhino, groovy, ruby and so on)? I only found the runtime
> environment.
> 
> PS: Manually downloading it is no option in my case.
> 

--

-- 
View this message in context: http://old.nabble.com/Quick-question%3A-jythonc-via-Maven--tp27458817p27458863.html
Sent from the jython-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
Oti | 5 Feb 12:14
Picon
Gravatar

Re: Quick question: jythonc via Maven?

Hi,

assuming you want to execute a series of Jython statements (please
correct me if i am wrong), i'd recommend to use the exec method of
PythonInterpreter instead of jythonc.

Maybe you could use http://ant.apache.org/manual/OptionalTasks/script.html

But i must confess i don't know enough about maven to really
understand the 'execute without download' mechanisms.

Hope to help a little,
Oti.

On Thu, Feb 4, 2010 at 9:01 PM, stephanos <exe2 <at> gmx.net> wrote:
>
> By the way - it's for a good cause:  http://codingkata.org/ codingkata.org .
> A site where you can solve various programming problems with 'any' JVM
> language
> (the 'any' part is why I asked this question - Jython would be a great
> addition to the site!).
>
>
> stephanos wrote:
>>
>> Is there any way to download+call jythonc via maven (e.g. antrun etc.)
>> (just like rhino, groovy, ruby and so on)? I only found the runtime
>> environment.
>>
>> PS: Manually downloading it is no option in my case.
>>
>
> --
> View this message in context: http://old.nabble.com/Quick-question%3A-jythonc-via-Maven--tp27458817p27458863.html
> Sent from the jython-users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Jython-users mailing list
> Jython-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jython-users
>

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com

Gmane