Ok, well don't call the Map methods. Jython is intercepting the calls somehow (I have yet to figure out where) and if I don't expose them now I cannot call them like I thought I could.  Here is what I got before 'exposing'.  Notice Jython blocks even the method calls to PyDictionary itself. 

>>> pyd

{3: 'spam', 2: 'bar', 1: 'foo'}

>>> pyd[1]

'foo'

>>> pyd.keySet()

Traceback (innermost last):

  File "<console>", line 1, in ?

AttributeError: 'dict' object has no attribute 'keySet'

>>> pydo = PyDictionary()

>>> pydo = PyDictionary(pyd)

>>> pydo

{3: 'spam', 2: 'bar', 1: 'foo'}

>>> pyd

{3: 'spam', 2: 'bar', 1: 'foo'}

>>> pydo.keySet()

Traceback (innermost last):

  File "<console>", line 1, in ?

AttributeError: 'dict' object has no attribute 'keySet'

>>> isinstance(pydo,Map)

0

Is there another way I've not found yet; in other words to partially expose so Python only sees Python methods and Java sees everything?  Does that even make sense as long as we meet the Python contract?  If we provide more functionality I don't particularly see it as being a down side. 



-----Original Message-----
From: Samuele Pedroni [mailto:pedronis@strakt.com]
Sent: Friday, April 08, 2005 4:23 PM
To: Mike Garcia (Paris)
Cc: Brian Zimmer; Mike Garcia; jython-dev@lists.sourceforge.net
Subject: Re: [Jython-dev] 22a1 PyDictionary exposed as 'dict'

Mike Garcia (Paris) wrote:

> I'm stoked!!  Got the first containsKey Map method running in the new

> style pyDictinoary.  There is a special way to configure the methods

> you want exposed to jython.  Basically you have to create an 'exposed'

> class that extends PyBuiltinFuntionNarrow and set it accordingly.

>

> I'll have to spend a couple of days to pick up all of the Map

> implementations on the new style PyDictionary but I think it looks good.

>

>

but we don't want them exposed on Python side!

>>>> execfile(r"c:\jython21\jython_latest\tests\imports.py")

>

> Put some stuff into a python dictionary

>

> {987: val2, 234: foobar, 1: val1}

>

>>>> pyd

>

> {987: val2, 234: foobar, 1: val1}

>

>>>> pyd[987]

>

> Traceback (innermost last):

>

>   File "<console>", line 1, in ?

>

> KeyError: 987  * <<<<<<<<<<<<<<<<<<<<  This is funky though, does not

> work with an imported dictionary*

>

>>>> pyd[9899]=123434

>

>>>> pyd[9899]

>

> 123434

>

>>>> pyd.containsKey()

>

> Traceback (innermost last):

>

>   File "<console>", line 1, in ?

>

> TypeError: containsKey() takes exactly one argument (0 given) <<< way

> cool, huh?!

>

>>>> pyd.containsKey(9899)  <*< yes!!*

>

> 1

>

>>>> pyd.containsValue(9899) * << just checking my sanity... (to be done)*

>

> Traceback (innermost last):

>

>   File "<console>", line 1, in ?

>

> AttributeError: 'dict' object has no attribute 'containsValue'

>

>>>> pyd.containsKey(987)* <<<<<<<<<<<<<<<<<<<<  This is funky though,

> does not work with an imported dictionary*

>

> 0

>

>>>> pyd.containsKey(9)* <<<<<<<<<<<<<<<<<<<<  This is funky though,

> does not work with an imported dictionary*

>

> 0

>

>>>> pyd

>

> {9899: 123434, 987: val2, 234: foobar, 1: val1}

>

>>>> pyd.containsKey(1)

>

> 0

>

>>>> isinstance(pyd,Map)* <<<<<<<<<<<<<<<<<<<< ** This bothers me**

> becaus**e it should tell me TRUE now*

>

> 0

>

>>>> hm=HashMap(pyd)* <<<<<<<<<<<<<<<<<<<< ** What we are** looking**

> for right*

>

>>>> hm

>

> {<javainstance object 1>=<javainstance object 2>, <javainstance object

> 3>=<javainstance object 4>, 9899=123434

>

> , <javainstance object 5>=<javainstance object 6>}*<<<<<<** Yuck, what

> up w/ the repr!*

>

>>>> hm.containsKey(9899)

>

> 0

>

>>>> hm.containsKey(1)

>

> 0

>

>>>> hm.keySet()

>

> [<javainstance object 1>, <javainstance object 3>, 9899, <javainstance

> object 5>]

>

>>>> iter = hm.keySet().iterator()

>

>>>> iter.hasNext()

>

> 1                              * <<<<<<<<<<<<<<<<<<< ** Our

> PyDictionary created data in a new HashMap*

>

>>>> iter.next()

>

> 987                            * <<<<<<<<<<<<<<<<<<< ** Our

> PyDictionary created data in a new HashMap*

>

>>>> iter.next()

>

> 1                              * <<<<<<<<<<<<<<<<<<< ** Our

> PyDictionary created data in a new HashMap*

>

>>>> iter.next()

>

> 9899                           * <<<<<<<<<<<<<<<<<<< ** Our

> PyDictionary created data in a new HashMap*

>

>>>> iter.next()

>

> 234                            * <<<<<<<<<<<<<<<<<<< ** Our

> PyDictionary created data in a new HashMap*

>

>>>> iter.hasNext()

>

> 0

>

>>>> hm

>

> {<javainstance object 1>=<javainstance object 2>, <javainstance object

> 3>=<javainstance object 4>, 9899=123434

>

> , <javainstance object 5>=<javainstance object 6>}

>

>>>> pyd

>

> {9899: 123434, 987: val2, 234: foobar, 1: val1}

>

>>>> pyd.containsKey(9899)

>

> 1

>

>>>> 1==1 * <<<<<<<< couldn't believe it*

>

> 1

>

>>>>

>

> Hope to get a patch in soon for this baby along with the new PyIterator.

>

> Re,

>

> Mike

>