NWP 2.1 Sandbox Breaks AppleScript
NWP 2.1 Sandbox Breaks AppleScript
I love the new version and many of its features.
However, I am unable to solve an issue with some AppleScripts that call on Nisus templates. After NWP 2.1 moved the file templates to ~/Documents/Nisus Documents/Templates/, my scripts are interrupted with this error:
The file "Nisus New File" could not be opened.
permission was denied: ~/Documents/Nisus Documents/Templates/Nisus New File.dot [NSCocoaErrorDomain - code 257]:
~/Documents/Nisus Documents/Templates/Nisus New File.dot
And Nisus Writer hangs with this message in the frontmost window’s status bar:
"Running Macro 'Unsaved Script'"
Any suggestions?
Thanks.
Richard Hart
However, I am unable to solve an issue with some AppleScripts that call on Nisus templates. After NWP 2.1 moved the file templates to ~/Documents/Nisus Documents/Templates/, my scripts are interrupted with this error:
The file "Nisus New File" could not be opened.
permission was denied: ~/Documents/Nisus Documents/Templates/Nisus New File.dot [NSCocoaErrorDomain - code 257]:
~/Documents/Nisus Documents/Templates/Nisus New File.dot
And Nisus Writer hangs with this message in the frontmost window’s status bar:
"Running Macro 'Unsaved Script'"
Any suggestions?
Thanks.
Richard Hart
Al Hatch
Re: NWP 2.1 Sandbox Breaks AppleScript
Yes, Sandbox breaks AppleScript. What use are you making of AppleScript?
If you are using AppleScript to access other applications, you will have to rewrite things to use them as a service. Having a Nisus Macro call AppleScript with a "Run AppleScript" command will no longer work (in the majority of situations).
Otherwise it would seem best to use the Nisus Macro Language, if possible, and drop the use of AppleScript altogether.
If you are using AppleScript to access other applications, you will have to rewrite things to use them as a service. Having a Nisus Macro call AppleScript with a "Run AppleScript" command will no longer work (in the majority of situations).
Otherwise it would seem best to use the Nisus Macro Language, if possible, and drop the use of AppleScript altogether.
philip
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: NWP 2.1 Sandbox Breaks AppleScript
Philip is correct, now that Nisus Writer Pro (NWP) version 2.1 is sandboxed, the use of AppleScript has been restricted. You might read this thread which includes a detailed discussion on the matter a few posts down.
Please let us know what your macro is trying to accomplish exactly. We should be able to figure out a way to accomplish the same in NWP 2.1 using either the Nisus macro language, or an AppleScript that is invoked externally.
Please let us know what your macro is trying to accomplish exactly. We should be able to figure out a way to accomplish the same in NWP 2.1 using either the Nisus macro language, or an AppleScript that is invoked externally.
Re: NWP 2.1 Sandbox Breaks AppleScript
This actually doesn't sound like an Applescript error. That folder is a Nisus folder; it sounds more like part of the file system sandbox is being tripped instead of an Applescript error (If Nisus can read it, so should any Applescripts Nisus runs). Perhaps there's an issue with the macro's getting access to that particular sandboxed folder?
Re: NWP 2.1 Sandbox Breaks AppleScript
All of my AppleScripts are external to Nisus Writer Pro. Two of them join a number of messages in Outlook and in Mail, then pass the clipboard to NWP.martin wrote:Please let us know what your macro is trying to accomplish exactly.
Code: Select all
... set the clipboard to outlookMessages
end tell
end dumpMessages
on clipboardToNisus()
global outlookMessages
try
tell application "Nisus Writer Pro"
activate
set outlookDump to "/Users/richard/Documents/Nisus Documents/Templates/Nisus New File.dot"
open outlookDump...
Al Hatch
Re: NWP 2.1 Sandbox Breaks AppleScript
Okay, I'm not sure on the permissions bit (I'd recommend selecting the file in the Finder, doing a "Get info" command and making sure the permissions are set to everyone read/write/create on it), but my suggestion is to change your approach.
Instead of trying to open the template file, just create a new document:
You are creating a new file the hard way, and it's not a surprise it is breaking. Now, if you have a specific template in mind for Nisus to be opening, then I'd suggest using Nisus' macro language to do that (Direct support in Nisus for Applescript is limited; frankly I'm amazed that you are accomplishing what you are with pure Applescript).
Instead of trying to open the template file, just create a new document:
Code: Select all
tell Nisus Writer Pro
Create new file
.... paste the clipboard, etc.
end tell
Re: NWP 2.1 Sandbox Breaks AppleScript
Using "Open" in an AppleScript like this will not work. It will give you a permissions error. Ideally one should be able to precede this with a "File.requireAccessToFileAtPath" command, but this has not worked for me. It seems to be a bug.hatchmo wrote:All of my AppleScripts are external to Nisus Writer Pro. Two of them join a number of messages in Outlook and in Mail, then pass the clipboard to NWP.martin wrote:Please let us know what your macro is trying to accomplish exactly.Everything after this works fine. AppleScript tells NWP to paste the clipboard, then to move the pointer to the start of the new document, set the font, etc. The problem is the line ending with Nisus New File.dot. That's the one that throws the permissions error.Code: Select all
... set the clipboard to outlookMessages end tell end dumpMessages on clipboardToNisus() global outlookMessages try tell application "Nisus Writer Pro" activate set outlookDump to "/Users/richard/Documents/Nisus Documents/Templates/Nisus New File.dot" open outlookDump...
philip
Re: NWP 2.1 Sandbox Breaks AppleScript
According to the release notes for Nisus 2.1.1 (that is in Beta, so it's not been publicly released yet); this issue may be fixed.
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: NWP 2.1 Sandbox Breaks AppleScript
That is correct: all of the File commands in Pro 2.1 related to sandbox access did not function via AppleScript.phspaelti wrote:Using "Open" in an AppleScript like this will not work. It will give you a permissions error. Ideally one should be able to precede this with a "File.requireAccessToFileAtPath" command, but this has not worked for me. It seems to be a bug.
That's also true. We fixed the problem of using File commands via AppleScript in the just released public beta of Pro 2.1.1. You can download the Pro 2.1.1 beta here. The beta should be relatively stable, since the number of changes is small and focussed, but all the usual warnings about running beta software apply. We expect to have a proper release soon enough.Vanceone wrote:According to the release notes for Nisus 2.1.1 (that is in Beta, so it's not been publicly released yet); this issue may be fixed.
Re: NWP 2.1 Sandbox Breaks AppleScript
Thanks, everyone, for the help and suggestions here. They have led me to a working rewrite of my AppleScripts. And I appreciate Nisus for spending the time and effort even on these "special" cases.
Al Hatch