• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

catalog:get/setPropertyForPlugin

Community Beginner ,
Jul 10, 2010 Jul 10, 2010

Copy link to clipboard

Copied

Is anybody using the new catalog get and setPropretyForPlugin yet?

The SDK isn't very explicit on how these work - my take is that they allow a plugin to create metadata fields on the catalog (rather than photos) and that you don't have to define the field in advance...

However, I can not seem to get them to work at all.

     local catalog = LrApplication.activeCatalog()

     LrTasks.pcall( function() catalog:withWriteAccessDo( "Set some metadata",

          function()

               catalog:setPropertyForPlugin(_PLUGIN, "fred", "Some stuff")

               catalog:setPropertyForPlugin(_PLUGIN, "john", "Other stuff")

          end)

          local linkIDList = catalog:getPropertyForPlugin(_PLUGIN, "fred")

          local linkNameList = catalog:getPropertyForPlugin(_PLUGIN, "john")

     end)

Anyone any ideas?

Cheers

Mark.

TOPICS
SDK

Views

2.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 10, 2010 Jul 10, 2010

Copy link to clipboard

Copied

I'm not sure what symptoms you were having, but I just tried it and this is what happened:

catalog:setPropertyForPlugin - executed without error.

catalog:getPropertyForPlugin - caused an error with trapped message: "Could not copy value between states" - which the same error I get if I pass a "surelynottobefoundname" for the field-name.

Is there a secret?

Rob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2010 Jul 11, 2010

Copy link to clipboard

Copied

That is the same symptoms Rob.  Did you copy and paste my code or use your own?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2010 Jul 11, 2010

Copy link to clipboard

Copied

Mark,

I used my own code, and I played with it a fair bit - tried "get"-ing in a separate with____Do gate... - I think its broken!

Chet? Mr. Drarvik?? - You didn't quit already did you??? - Too busy to read the forum???? - Policy not to respond?????

Rob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2010 Jul 11, 2010

Copy link to clipboard

Copied

At the risk of stating the obvious, workaround-wise - If your property does not have to be specific to the catalog, then LrPrefs will do. And now that I think about it, you could always prepend the catalog id and roll your own catalog:set/get methods using prefs. Except I don't see how to obtain a catalog ID, hmmm.. you could use the path, but then if it got moved you'd be hosed. - Another feature request coming...

Rob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 12, 2010 Jul 12, 2010

Copy link to clipboard

Copied

Mark,

I believe you're trying to read items outside of a gate. Try changing your code as follows:

local catalog = LrApplication.activeCatalog()

LrTasks.pcall(
    function()
        catalog:withWriteAccessDo( "Set some metadata",
                                    function()
                                        catalog:setPropertyForPlugin(_PLUGIN, "fred", "Some stuff")
                                        catalog:setPropertyForPlugin(_PLUGIN, "john", "Other stuff")
                                    end)
        catalog:withReadAccessDo( "Read some metadata",
                                    function()
                                        local linkIDList = catalog:getPropertyForPlugin(_PLUGIN, "fred")
                                        local linkNameList = catalog:getPropertyForPlugin(_PLUGIN, "john")
                                    end)
    end
)

Sorry for taking the liberty and re-formatting the code to my liking

PS: Also, keep in mind, you can't write and read inside of the same callback function, you must let the "write" gate to complete and come back, only then you can "read".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 12, 2010 Jul 12, 2010

Copy link to clipboard

Copied

Thanks Vladimir.  You are right, my test code had the get calls outside the with_accessdo call - I must have got desperate trying anything

Following your comment of reading and writing in the same callback - if I move the gets to a separate "catalog:withReadAccessDo( function()" I still get the same copy between states error.  However, moving them to a complete new LrTask seems to work - although I haven't tested this completely yet.

Thanks for the help!  I'll post more when I get a chance to test the behaviour a little more.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 13, 2010 Jul 13, 2010

Copy link to clipboard

Copied

Mark,

If you are using two separate asyncronous tasks, chances are, they would be running in parallel. So the first task may still be "writing" when the second task is attempting to "read". Just something to watch out for.

Anyway, let us know what you find in your testing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 13, 2010 Sep 13, 2010

Copy link to clipboard

Copied

From the best I can tell this function is completely broken.

Has anyone ever gotten it to work???

Rob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 01, 2011 Oct 01, 2011

Copy link to clipboard

Copied

At some point in a Lr3 dot rev, Adobe nearly fixed this function.

@LR3.4.1, It *sometimes* works with private access, and it always(?) works with full write access.

I use a work-around now that just uses reglar lr-prefs-for-plugin and prefixes the catalog path (with illegal key chars removed) to the target property name.

Accomplishes the same thing for my purposes and is faster and more reliable and requires no with-do gate.

Rob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 05, 2011 Oct 05, 2011

Copy link to clipboard

Copied

LATEST

I'm finding this family of functions are very sensitive to timing, and the timing is very different in different interpreters and in different contexts (e.g., when run in your own dialogue vs. one of the SDK callbacks)

As pointed out, we end up being in a number of async tasks often, and I suspect much of my problems end up being routine contention.  Sometimes putting yileds() in silly places seems to help.

Other places, though, these accessors can be hacked on for days and nothing seems to help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines