[Pythonmac-SIG] Webbrowser module?

Steven Burr sburr@home.com
Fri, 11 Jan 2002 21:08:55 -0700


On Friday, January 11, 2002, at 02:27 AM, Jack Jansen wrote:

> This sounds like a nice stopgap. Could you try adding the IC stuff so
> that it really opens the users' default browser?

I'm not sure how to do this.  The open method in the InternetConfig 
class calls "ic.launch(url)."  If I try to import ic while running 
MachoPython in the Terminal, I get an ImportError.

BUT, I've run across something just as good, or at least close.  I was 
using the openURL command from the AppleScript dictionary for Internet 
Explorer.  Tonight I took a look at the Standard Additions dictionary 
and found an "open location" command that opens a url with the user's 
default browser!  I ran the command

The openURL command seems to be standard for scriptable browsers.  I 
found it in the AppleScript dictionaries for IE, OmniWeb and Netscape.   
By using both that and the open location command, I believe I can give 
MachoPython users of webbrowser the same options that other Unix users 
have:  choose a browser or rely on the default.  I'll work on it and 
send in another patch.

> This shouldn't be too
> difficult, . . . .

Probably not, for you.  : )  But I'm just hobbyist.

> One thing, though: what will happen if you run this when you don't
> have access to the window server? I.e. when you're on Mac OS X Server,
> or when you're in an ssh session to an OSX machine where you ar enot
> logged in on the console?

I can test a couple of scenarios where no window manager is available.  
I can start my Mac in console-only mode, and I can access my other Mac 
with ssh.   I don't have access to OS X Server, though.

>  Doing a Carbon call in such circumstances
> will crash Python, and that probably isn't acceptable...

I guess that means a try/except won't work.  : )