[IronPython] Using ruby module from python.

Tomas Matousek Tomas.Matousek at microsoft.com
Mon Nov 30 18:47:53 CET 2009


Our Python-Ruby interop is not quite done yet so you need to use some workarounds.

The easiest way how to get WSDL factory instance would be to write a simple Ruby script that loads it:

== wsdl.rb ==

require 'soap/wsdlDriver'

def get_factory
  SOAP::WSDLDriverFactory
end

===

And then you can do:
>>> import clr
>>> wsdl = clr.Use('wsdl.rb', 'rb')
>>> factory = wsdl.get_factory()
>>> print factory("x.wsdl")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: Cannot connect to x.wsdl (Not HTTP.)


get_factory method is exposed on the "wsdl" module so that Python can call it. IronRuby doesn't yet implement dynamic protocols for constant access so you need the get_factory helper for accessing Ruby constants.
Also we have some work to do to make clr.Use work better with libraries of other DLR languages.
Let us know if you hit some other issues.

Tomas


-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Pavel Suhotyuk
Sent: Monday, November 30, 2009 2:38 AM
To: Discussion of IronPython
Subject: [IronPython] Using ruby module from python.

Hello.

I want try to use ruby library (soap) in python code.
I found method Use(str) in clr module for load the specified module searching all languages in the loaded ScriptRuntime, but don't understand how to used it.

I try to call this method in any variants, but nothing happends.

 >>> import clr
 >>> clr.Use('soap/wsdlDriver')
Traceback (most recent call last):
   File "<string>", line 1, in <module>
ValueError: couldn't find module soap/wsdlDriver to use  >>> clr.Use('soap.wsdlDriver') Traceback (most recent call last):
   File "<string>", line 1, in <module>
ValueError: couldn't find module soap.wsdlDriver to use  >>> clr.Use('soap/wsdlDriver.rb') Traceback (most recent call last):
   File "<string>", line 1, in <module>
ValueError: couldn't find module soap/wsdlDriver.rb to use  >>> clr.Use(r'''C:\usr\env\IronRuby\lib\ruby\1.8\soap\wsdlDriver.rb''',
'rb')
<module '?' (built-in)>
 >>> m =
clr.Use(r'''C:\usr\env\IronRuby\lib\ruby\1.8\soap\wsdlDriver.rb''', 'rb')  >>> m <module '?' (built-in)>  >>> dir(m) ['__builtins__']


Thanks.
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com




More information about the Ironpython-users mailing list