[Pythonmac-SIG] CFURL Pain

has hengist.podd at virgin.net
Thu Mar 3 16:31:29 CET 2005


Paul Berkowitz  wrote:

>The type 'alias' for the Save command in the Standard Suite is a long,
>longstanding bug in AppleScript.

Replacing (as of 10.3) a previous long, longstanding implementation 
bug where it was specified as a POSIX path string. :p

I take it 'alias' is just a documentation error then, and the 
application will also accept a file spec/file url type identifying an 
existing/not-yet-created file.


>Fortunately there is an equally
>longstanding coercion, performs by AppleScript itself, that allows you to
>use a string or Unicode text there

Presumably there's a POSIX path string-to-file object coercion 
introduced in 10.3 to maintain compatibility scripts written for 
Cocoa apps in 10.2, where 'save...in' took a POSIX path string 
instead of a file object.

In aem's case at least, I'd be extremely reluctant simply to replace 
all use of Mac file objects with POSIX path strings. I've already 
tried this once and it just caused problems. I really would like an 
elegant, easy-to-use solution that respects AE file objects and 
provides user-friendly Python equivalents that hide as much of the 
underlying clumsiness without introducing any new problems. Might be 
a non-trivial task, but I think it'd be worth doing, especially if 
Python's to become a genuine replacement for AppleScript.


>In OS X, the coercion is now to fileURL,
>I believe. Whether this coercion takes place at a deep enough level
>(AppleEvent?) that it will work also for appscript and MacPython, I don't
>know. If you try it, what happens?

I've tried supplying FileURLs to Tex-Edit Plus in 10.2 and it seemed 
to work ok. If CFURL worked properly I'd probably just sling in the 
code to coerce AEDescs of typeFSSpec and typeFSRef to typeFileURL and 
spit out CFURLs, then wait and see if anyone runs into problems. 
NSURL is an alternative, though I'm still a little uncomfortable 
about coupling aem to PyObjC just for the sake of one little type; 
I'll think about this a bit more.

It would definitely be nice if the whole Mac file type muddle could 
be reduced - at least at the end-user level - to high-level, 
user-friendly FileURL and Alias classes. The only questions are: can 
we get there safely, and if so, how?

Cheers,

has
-- 
http://freespace.virgin.net/hamish.sanderson/


More information about the Pythonmac-SIG mailing list