You are not logged in Log in Join
You are here: Home » Members » The Feneric Zope Page » Using External Editor with Mac OS X

Log in
Name

Password

 

Using External Editor with Mac OS X

 

Created by Feneric . Last modified 2005-02-05 03:41:32.

A brief tutorial on how to set up a Mac OS X system to work with External Editor.
Please note that while this procedure has been tested and still works as written with the latest versions of Aqua Tk, the framework install of Python, the UNIX version of the Zope External Editor, BBEdit UNIX tools, and OpenOffice (not to mention various additional applications like NeoOffice and ReSTedit) I personally now use (and heartily recommend) the ZopeEditManager application instead. It supports everything the method outlined here does, and is much easier to set up, configure, and tweak.



Using External Editor with Mac OS X

This short document outlines the steps I took to make Caseman's External Editor product work under Mac OS X. I've used these exact steps on two different Macs of different architectures (one G3 PowerBook and one G4 Desktop). I've also got External Editor running on a dual-processor G4 desktop, so I'm pretty confident that it should be possible to run External Editor on any current (or semi-current) Mac provided that it's running a new enough version of Mac OS X. I've only personally tried 10.2.1 and later versions, but it'll probably work on earlier versions, too.

Steps to get Zope External Editor working under Mac OS X:

  1. Install the Tk library.

    Go to the Mac OS X Downloads section of the Apple web site and search for "Tk" (without the quotes). Download the latest version of Tk Aqua (8.4.2.0 as of this writing) and install it (the "easy install" option is fine). As this installation involves libraries, you'll need the system administrator password, but you won't need to reboot. Among other things, this install will create a /usr/local/ directory that will be used in later steps.

    I can't fathom why Tk isn't installed along with Tcl by default on Mac OS X. While you're waiting for the install to complete, why not drop Apple a line at http://www.apple.com/macosx/feedback/ and let them know that Aqua Tk is a reasonable default install in an environment that has Tcl, Python, and Perl (all of which can make good use of Tk) already preinstalled, and make the Tk library available to them.



  2. Build and install optional libraries.

    This step is completely optional, but since Python will have to be built from source anyway in the next step it's not too much extra work and can make for a more capable Python installation. The library I most strongly recommend is the readline library; basic editing commands in the Python shell are sorely missed without it.

    In any case, building readline is not too hard. Download the latest (4.3 as of this writing) from http://www.gnu.org/directory/readline.html and unpack it (probably StuffIt Expander will do so for you auto- matically). Enter its directory from within a terminal window (via a command like

    cd readline-4.3

    and type the following two commands:

    ./configure --disable-shared

    and

    make

    This will build the readline library (the current version seems to have problems building a shared library; I haven't really spent the time to investigate further as it's not really needed anyhow). Typing the command sudo make install will install it.

    I strongly feel that this library ought to be already linked into the Python that Apple has preinstalled on Mac OS X. If you do likewise, why not drop them a feedback note at the address mentioned above while you're waiting for readline to build?

    Other optional libraries like gdbm can be installed in a similar manner if desired.



  3. Build Python from source and install it.

    Go to http://www.python.org/ and find and download the latest Python tarball (Python-2.3a2.tgz as of this writing) and unpack it (probably StuffIt Expander will do so for you automatically). Note that it is quite possibly an alpha release -- there are some significant Mac OS X improvements between the 2.2 and 2.3 series, so it makes sense to get the 2.3 version even if it's only an alpha. In particular, I have not been able to get the 2.2 release to work with the binary Tk release mentioned above (although I was able to the 2.2 release work with Tcl/Tk built completely from source by playing around with the Setup file -- if you want to take this route, it is doable, just less direct).

    Open a terminal window (if you've installed readline as suggested above you've already got one) and navigate within it to the Python source directory that you've just unpacked. Type

    ./configure --enable-framework

    and wait a bit.



    Type

    make

    and wait a bit longer (in fact, on this G4 there's time to go get a cup of tea -- if you haven't sent any feedback to Apple yet about how if Tk, readline, Open SSL, and Python were all preinstalled in a friendly manner you wouldn't need to be wasting this time right now, now's a good time to consider doing so).

    Finally, type

    sudo make frameworkinstall

    There will be a bit more of a wait afterwards, but Python with Tkinter (and readline if you built it) will have been installed when it completes.



  4. Install the Zope External Editor Helper Application (UNIX Version)

    Copy zopeedit.py into /usr/local/bin either via the finder (you'll have to use the "Go to Folder" menu item as /usr/local/bin is normally invisible and you may have to play with permissions) or via a command like sudo cp zopeedit.py /usr/local/bin in the terminal (assuming that zopeedit.py is in the current directory). Modify the first line of it to read

    #!/usr/bin/env pythonw

    and you may just as well add the line

    macosx = sys.platform == 'darwin'

    under the

    win32 = sys.platform == 'win32'

    while you're in there (if it's not already present).



  5. Install the ZopeEdit AppleScript

    This AppleScript can be put in /usr/local/bin and is used to call the zopeedit.py file (Mozilla does not recognize zopeedit.py as a valid helper application, but it will recognize an AppleScript). Note that currently this script is actually configured to call zopeedit.pyc, the compiled form of zopeedit.py. Either zopeedit.py can be compiled (via importing it from the Python command line) or the script can be modified to call zopeedit.py directly to make it work properly.



  6. Configure your favorite browser

    This is done mostly as described in the UNIX documentation, but it may be necessary to have the browser reference the AppleScript instead of the zopeedit.py file.

    I have only personally gotten this working with Mozilla (and have been using it with Mozilla since version 1.1 if I recall correctly); neither Camino nor Safari seem to allow setting helper applications based on MIME type, so neither of these browsers will currently work with Zope External Editor (if you know of a way to make either of these work, in particular Camino, please let me know). I have not tried MSIE, Opera, iCab, OmniWeb, etc.



  7. Edit your ~/.zope-external-edit file

    Configure this as per the main documentation. I've been using it reliably with both BBEdit and OpenOffice. (See also my tip for BBEdit.)