Message Board for Rorohiko Workflow Resources
https://www.rorohiko.com/cgi-bin/yabb2/YaBB.pl
General Category >> General Board >> APID  - how to access all dataStore entries?
https://www.rorohiko.com/cgi-bin/yabb2/YaBB.pl?num=1232285960

Message started by weller on 01/19/09 at 01:39:20

Title: APID  - how to access all dataStore entries?
Post by weller on 01/19/09 at 01:39:20
Is there a way to retrieve an array or object with all saved variables?
I know I can use item.getDataStore('key'), but that can only help if I know the keys.


Thanks for help
weller

Title: Re: APID  - how to access all dataStore entries?
Post by Harbs on 01/19/09 at 04:57:51
You're joking. Right?

You're asking if there's a skeleton key or a lock-pick set?  :o

Keys are for locking doors!  ;D

Title: Re: APID  - how to access all dataStore entries?
Post by Kris Coppieters on 01/19/09 at 06:10:36
Hi Weller,

Harbs is correct - you're not meant to be able to do that. The 'dataStore' is 'shared space' between multiple developers, and each developer can currently make sure that space stays private by choosing 'secret' keys - you don't want developer A to go poking into developer B's datastores.

So - it's a feature, not a shortcoming!

If you add multiple data store entries and you want to iterate _your_ private entries, one approach is to keep a 'table of contents' of all keys you create and store that into an additional entry - something like (pseudocode - I've not checked my syntax):

[code]
function mySetDataStore(theItem,theKey,theValue)
{
 // extract current table of contents for item. Could be a string or an array
 var theTableOfContents = theItem.getDataStore("com.mycompany.myplugin.mytableofcontents");

 // add if not in table yet - using a string in this example. Assumes keys don't contain "/" char
 // 'Jams' keys between two "/".
 if (theTableOfContents == undefined)
 {
   theTableOfContents = "/" + theKey + "/";
   theItem.setDataStore("com.mycompany.myplugin.mytableofcontents",theTableOfContents);
 }
 else if (theTableOfContents.indexOf("/"+theKey+"/") < 0)
 {
   theTableOfContents += theKey + "/";
   theItem.setDataStore("com.mycompany.myplugin.mytableofcontents",theTableOfContents);
 }

 theItem.setDataStore.setDataStore(theKey,theValue);
}
[/code]

and you then religiously use mySetDataStore instead of .setDataStore, you'd end up with an interable table of contents of your keys (e.g. "/mykey1/mykey2/mykey123/") which is easy to split up and iterate.

Cheers,

Kris

Title: Re: APID  - how to access all dataStore entries?
Post by weller on 01/19/09 at 10:29:37
Thank you for help. The TOC approach works great for me.
It wasn't my intention to ask for anything inappropriate. I'm using APID only to improve my own workflows. That is why I live in blissful ignorance of any security issues.

Message Board for Rorohiko Workflow Resources » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2024. All Rights Reserved.