[Pythonmac-SIG] scripting over Distributed Objects
Georg Seifert
georg.seifert at gmx.de
Fri Jun 12 01:56:28 CEST 2009
Hi,
I try to script me app using the JSTalk framework. My app i written in
cocoa. I works nice with Javascript and if I use python from within my
app with "PyRun_SimpleString" but if I use python over the DO
connection I get problems.
What the JSTalk framework does is it establishes a connection between
two app (or one app and a python interpreter) over Distributed Objects.
In the script I get a reference to my NSApplication delegate and can
use all its properties and function. But if I add some objects to my
documents it works only as long as the script runs. It is a problem
with the proxy objects. As long as the script runs, the proxy is
working and the pyObjC bridge routes the method calls correctly.
I resolved this with copying the object in my accessors but then the
reference to the object in the script becomes invalid (and I need an
extra copy)
Does anybody has an idea what to do?
Can I somehow make python to return the actual cocoa object rather
than the proxy?
Many Thanks
Georg
excerpt of my python code:
[..]
def application(appName):
appPath =
NSWorkspace.sharedWorkspace().fullPathForApplication_(appName);
appBundle = NSBundle.bundleWithPath_(appPath)
bundleId = appBundle.bundleIdentifier()
[..]
port = bundleId + ".JSTalk"
conn = None
tries = 0
while ((conn is None) and (tries < 10)):
conn = NSConnection.connectionWithRegisteredName_host_(port, None)
tries = tries + 1;
if (not conn):
time.sleep(1)
if (not conn):
print("Could not find a JSTalk connection to " + appName)
return None
return conn.rootProxy()
glyphs = application("Glyphs") # the reference to my App delegate
node = glyphs.node() # I need the method return a new instance as I am
not in the scope of my app and python does not know of my classes.
[..]
path.addNode_(node)
More information about the Pythonmac-SIG
mailing list