Luke George 2 Posted July 25, 2019 Share Posted July 25, 2019 Hi there, I am trying to implement an IronPython script found herehttps://community.spotfire.com/wiki/ironpython-script-save-file-locally-or-library-tibco-spotfiredesigned to save a file to a library. The code looks like this: # Import namespaces from Spotfire.Dxp.Framework.ApplicationModel import ApplicationThread from Spotfire.Dxp.Application import DocumentSaveSettings from Spotfire.Dxp.Framework.Library import * # Declaring the function which will run async def saveAsLibraryItem(app, folder, fileName, metaData, saveSettings): def f(): app.SaveAs(folder, fileName, metaData, saveSettings) return f # save local def saveAsLocal(app, folderName, fileName, saveSettings): def f(): fullPath = folderName + fileName app.SaveAs(fullPath, saveSettings) return f # Save as library item LibraryfolderName = "/GV" LibraryfileName = "Test" # Set up the LibraryManager and ensure that we can # access the folder path specified libraryManager = Document.GetService(LibraryManager) success, libraryFolder = libraryManager.TryGetItem(LibraryfolderName, LibraryItemType.Folder) # Executing the function on the application thread, and Save the document back to the Library Application.GetService[ApplicationThread]().InvokeAsynchronously(saveAsLibraryItem(Application, libraryFolder, LibraryfileName, LibraryItemMetadataSettings(), DocumentSaveSettings()))However, I keep getting the following error: "TypeError: cannot access protected member GetService without a python subclass of Document" Any idea how to work around this Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted August 7, 2019 Share Posted August 7, 2019 Can you try to change the following code libraryManager = Document.GetService(LibraryManager)to this, libraryManager = Application.GetService(LibraryManager) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now