8 Replies Latest reply on Nov 4, 2009 2:56 AM by john beardsworth

    Access custom metadata from another plugin

    Allen Gambrell Level 1

      I was wondering if it would be possible to access the custom metadata from one plugin from another plugin.

       

      I know you use the _PLUGIN object when you read or write the metadata with a plugin.Is there any way to pass the varible to another plugin, maybe stored in a xml or text file in the modules folder? I also see where you can use the "unique identifying string" or plugin.id. Is this id differant for every installation of Lightroom?

        • 1. Re: Access custom metadata from another plugin
          john beardsworth Adobe Community Professional & MVP

          Allen, I'm pretty sure the answer is no - you can't access another plug-in's custom fields.

           

          I'm sure I have read this limitation somewhere - even if I can't now see it stated explicitly in the documentation. If anything, the docs imply getPropertyForPlugin can do so by specifying the LrToolkitIdentifier value (which you may be able to pass as a preference). So this doesn't work:

           

               getData = photo:getPropertyForPlugin("uk.co.beardsworth.missing", jbMissing )

           

          It is an important point though that one plug-in should be able to access another's custom fields. Obviously one can think of many ordinary circumstances where it would be handy, but I'm more worried about the longer term DAM viability of custom metadata. Let's say I decided to release a plug-in based around custom fields and users entered metadata which had some value to them - whether that's just input time or business data (eg client or agency account number). Now move on to LR3 and the plug-in no longer works - I've disappeared, driven mad by SDK changes, or you're unwilling to pay my extortionate plug-in upgrade fee.

           

          Now what happens to that valuable metadata? The data is still in the database but you can't read it because the original plug-in's unavailable, and Adobe's built-in "All" Plugin Metadata panel only shows data from enabled plug-ins. It's not in the XMP either. You're stuffed - unless you're resourceful enough to reverse engineer chunks of the plug-in. Assuming that I encrypted my plug-in's code, that means you're going to have to dig around the SQL to figure out my plug-in's ID and its field names. Only then can you create a plug-in to rescue your custom data. And you've got to hope to hell that my plug-in didn't encrypt or obscure the values you entered.

           

          For me what this shows is

           

          1) You're taking a big risk if you store valuable custom metadata - if you can't sort it out yourself, should you do it?

          2) You should ensure any plug-in with custom metadata stores its field definitions in unencrypted files

          3) The All Plug-in Metadata panel needs to show all plug-in metadata

          4) The SDK should allow you to get custom metadata from other plug-ins

          4) Custom fields should be mapped to XMP

           

          Short answer - No.

           

          John

          • 2. Re: Access custom metadata from another plugin
            Allen Gambrell Level 1

            John, I agree with eveything you said. But the most important point to me is that the custom metadata HAS to be written to the xmp file!

             

            I was able to access the data from another plugin using the following.

            newstr = photo:getPropertyForPlugin("com.adobe.lightroom.sdk.barcodematch",'FirstName'))

            where com.adobe.lightroom.sdk.barcodematch is the custom unique name of one of my other plugins.

             

            But there is still a problem. The plugin will not work if the other plugin is not loaded and I don't know how to check this.

             

            Using this meathod the other plugins data must be hard coded. We still need a way to access other plugins data without knowing what is availible at the time on coding. The plugin needs to a way to get a list all other plugins custom metadata at runtime.

             

            I think we could solve this one way.

            If every developer would output a list of there custom metadata avaible to a text or xml file in their plugin directory. We would need to set a standard for this file. It would have to include the plugin's custom id, Field name, and values availble. The plugin could then loop though all the plugin folders in the modules folder and find this text file and load the list of options into its plugin.

             

            I am going to work on this and see if I can get anywhere. If anyone has any other suggestions or items needed in the file please let me know.

            • 3. Re: Access custom metadata from another plugin
              john beardsworth Adobe Community Professional & MVP

              Hm, that's odd, because your code and mine are the same (apart from a stray parenthesis). I tested before posting and have looked at this before, so I'll have to check it again. Who knows what breaks code though? I was trying to get the value of an enum field, and I also referred to my own url (there's something in the docs about com.adobe.lightroom being reserved).

              • 4. Re: Access custom metadata from another plugin
                Allen Gambrell Level 1

                Huh, did not know anything about reserved. I just started from the sample plugins and changed what I though was needed. When I release the plugin do I need to change the id to something of my own? I thought they all were supposed to start with the com.adobe.lightroom.sdk

                • 5. Re: Access custom metadata from another plugin
                  john beardsworth Adobe Community Professional & MVP

                  Right now I can't find where I saw it (in the PDF?), and "reserved" is slightly too strong, but there is a comment along those lines and which said that it should be along the lines of mine - a reversed url. You never know when these things come back to bite you.

                  • 6. Re: Access custom metadata from another plugin
                    john beardsworth Adobe Community Professional & MVP

                    p20 of the PDF:

                     

                    Note that com.adobe.*, which is used in the examples, is
                    reserved for plug-ins written by Adobe; your own plug-ins
                    will use your own domain name (com.myCompany.*).

                    • 7. Re: Access custom metadata from another plugin
                      Allen Gambrell Level 1

                      Thanks, looks like I will be changing that in my plugins.

                      Will let you know if it stops working then.

                      • 8. Re: Access custom metadata from another plugin
                        john beardsworth Adobe Community Professional & MVP

                        johnbeardy wrote:

                         

                        ...the docs imply getPropertyForPlugin can do so by specifying the LrToolkitIdentifier value (which you may be able to pass as a preference). So this doesn't work:

                         

                             getData = photo:getPropertyForPlugin("uk.co.beardsworth.missing", jbMissing )

                         

                        Oh yes it does (pantomine season is approaching after all). Note the lack of quotes around jbMissing - fine if it's a variable, damn stupid if it's supposed to be a field name.