Jump to content

IronPython save file to library error


Luke George 2

Recommended Posts

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

  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...