Archive for the ‘OpenQwaq’ Category

OpenQwaq Python Integration

May 4, 2011

This is the first part of our series about the Cool bits of OpenQwaq. OpenQwaq has a complete integration with Python. What this means is that from OpenQwaq you can call Python code simply via something like here:

Python initialize. "initialize the bridge"
module := Python loadModule: 'ExampleModule'.
result := module call: 'add' with: 3 with: 4.
instance := module call: 'ExampleClass'.
instance call: 'exampleMethod' with: instance.

Of course, you can also do some fun reflective exercises such as:

Python initialize. "initialize the bridge"
modules := (Python loadModule: 'sys') get: 'modules'.
modules keys do:[:moduleName|
    moduleName = 'ExampleModule' 
        ifTrue:[Transcript show: 'ExampleModule is currently loaded']].

The bridge also allows callbacks from Python into Squeak code. From the Python you can talk back to Squeak like here:

import Squeak

def sampleCallback(rcvr, message):
    Squeak.send(rcvr, selector, ())

Squeak.send() function takes receiver, selector, and args and delivers it to the running OpenQwaq instance. OpenQwaq picks it up via the Python callback process and delivers it the proper receiver.

There is lots of fun stuff you can do that way. The best way to experiment with it, is to simply play around and inspect various results of operations. You can always dig deeper and you’ll almost certainly learn something about Python. I know I did 🙂


Cool Bits of OpenQwaq

May 4, 2011

Most of you have probably seen the announcement that the OpenQwaq Project is now available. I’d like to use that opportunity to highlight a couple of really interesting bits of OpenQwaq. I’m planning to start with the following topics:

  • Python Integration
  • Proxy and Firewall handling
  • Performance Profiling

As new stuff comes up, I might extend the series but three’s a charm so let’s start with those three.