Re: Transferring data between Python and Cocoa (maybe a newbie question)
Re: Transferring data between Python and Cocoa (maybe a newbie question)
- Subject: Re: Transferring data between Python and Cocoa (maybe a newbie question)
- From: has <email@hidden>
- Date: Wed, 6 Feb 2008 16:02:06 +0000
Nir Soffer wrote:
On Feb 6, 2008, at 00:51, Ritesh Nadhani wrote:
My app needs to connect to various servers to fetch similar data. The
issue is that the servers might use different way to get data. Some
use XML-RPC (majority of them are RPC), some use client-server etc.
User can add more server by adding a plugin. We already have bunch of
python scripts that just do that.
[...]
Now from Cocoa, I basically want to call these scripts with their
function common function name (which I know is implemented in all
python files) and get the result back.
[...]
The issue is that PyObjc is bundled only with 10.5 and for other OS X
version we have to install it.
You can add the needed parts from PyObjC to your app, the user will
not have to install anything. py2app will do this automatically for
you.
Yes, although py2app's usually used to build complete application
bundles from source. If you're wanting py2app to add Python libraries
to an existing Xcode project you may need to do a bit more research.
Best place to ask is on the PythonMac-SIG mailing list:
http://mail.python.org/mailman/listinfo/pythonmac-sig
For portability across major OS versions including 10.3, I'd recommend
embedding both a Python 2.5.1 interpreter and PyObjC 1.4 in your
application bundle. (I think PyObjC 2.0 requires 10.4 or later.)
Py2app can do this for you too, although only for Python frameworks
you've installed yourself; if you build against the Apple-installed
Python you'll get a semi-standalone application containing third-party
dependencies only.
http://python.org/download
http://pyobjc.sourceforge.net/downloads.html
Are these the only two options or there are other ways to do it? What
do you people suggest.
You can use WebServiceCore to do the rpc work directly in your app
instead of using Python.
You can use AppleScript to do the rpc work, and run it with
NSAppleScript. But I would not recommend it because AppleScript must
run the main thread and you want to do rpc in a background thread.
AppleScript is a complete PITA for any sort of multithreaded use and
its XML-RPC/SOAP facilities not the greatest, so personally I'd
suggest sticking with Python or similar for writing user-installable
plugins.
Aside from embedding PyObjC in your application, another couple of
possibilities would be:
1. Add a regular Cocoa-based plugin API and allow users to write
PyObjC-based plugins against that. Presumably you'd bundle Python and
PyObjC in your application and load it at runtime, or maybe supply it
the Python/PyObjC support as a Cocoa plugin itself as I believe
VoodooPad does.
2. Skip PyObjC and use Python's C API. This can get rather tedious if
you're passing complex data, plus you'll probably get to deal with
with Python's annoying Global Interpreter Lock, but is quite doable
(I've done it myself) and might be worth considering if your needs are
simple.
Again, best place to ask for further advice and suggestions on Python-
related stuff is probably the PythonMac-SIG mailing list.
HTH
has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden