Is there any way for a URL service (E.g. the code in the ServiceCode.pys file) to access the dictionary or data objects for the associated plugin using the Dict/Data API documented here? I'm trying to access some of the information stored in my plugin's dictionary to streamline the service code. For example, i need the session key i created in my main plugin code and stored in my plugin's Dict in order to make API calls.
So far i haven't had much luck. Just wanted to know if i was wasting my time.
Thanks!
Update:
To clarify, when trying to call Dict or Data i get errors such as:
device_id = Data.LoadObject("device_id")
NameError: global name 'Data' is not defined
or
session_id = Dict['session_id']
NameError: global name 'Dict' is not defined
It is not possible for URL Services to access persistent storage like that, nor can they have their own persistent storage. Perhaps there is another way to achieve what you're trying to do?
I'm sure there is. I could create a new session from within the service code and just duplicate the work my plugin did logging in the user and such. Just seems a little redundant. Though i guess i understand since the service code is used in other areas of Plex independent from the plugin. Was worth an ask. :)
From what I understand, if user-authentication is what you're dealing with, there will likely be improvements in the plugin framework's handling in the (hopefully not too distant) future.
You might be able to do this using Shared Code. I don't have any examples off the top of my head, but I think a few plugins are doing this sort of approach. Maybe the amazon video on demand channel uses this ... but that's just a guess. With that approach you would put the methods required for authentication or anything else you need to share into the shared code and then call it from either the channel or the URL service accordingly. I don't think it will do exactly what you are looking to do but it might work depending on your needs.
That's a good idea. I was thinking the same thing yesterday. The only hurdle i'll need to overcome is how to store data on the service code side. Is there any method currently available? Once my authentication code is moved to shared code, i'll still need a way to store the session_id and a few other variables created via the service code. If not i'll just wait for the update Mikedm139 spoke of and cross my fingers.
That I'm not sure about, I haven't personally done shared code before, but I know that some others have had success using it. I think in their cases they could just get things on demand from the provider and not have to store them.