Skip navigation
optimator999
Currently Being Moderated

Publish collection name rejection

Apr 23, 2012 8:38 PM

Tags: #validatepublishedcollectionname

Hello,

 

I'm developing a publish plug-in for lightroom. For clarity, the 'service' is where I'm publishing the photos to. The Collection Set name or the Collection name needs to be unique on the 'service' side. Therefore, I'd like to validate the Collection name against the 'service' and either accept or reject the proposed name.

 

The validatePublishedCollectionName function states:

 

you should accept the name here and reject the name when the server-side operation is attempted.

 

But, I don't know when the "server-side" operation is being performed. Is it in updateCollectionSettings? If so, how do I cancel the collection creation?

 

Thanks!

 
Replies
  • Currently Being Moderated
    Apr 23, 2012 9:24 PM   in reply to optimator999

    I'm outside my area of experience. Although the following would certainly be critical:

     

    * renamePublishedCollection

    * reparentPublishedCollection

     

    I can't see any function for initial creation/naming either though. Hmmmmm..... another hole?

     

    I suppose you could create an asynchronous task to poll the server for existing names, and if the results are not in yet, return false, "hang on..." from validatePublishedCollectionName, else compare entered value to existing names...

     

    Sorry if I've not been much help,

     

    Rob

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 24, 2012 3:28 PM   in reply to optimator999

    It seems my previously proposed solution would be better - so the user sees "bad name", instead of having their collection disappear.

    But I suppose as long as you prompt the user so it doesn't just seem flaky...

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 24, 2012 5:00 PM   in reply to optimator999

    Like Rob said, it looks like you're expected to do the server-side verification in

     

         renamePublishedCollection( publishSettings, info )

         reparentPublishedCollection( publishSettings, info )

     

    The doc states, "If your plug-in is unable to update the remote service for any reason, you should throw a Lua error from this function; this causes Lightroom to revert the change."

     

    -Don

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 25, 2012 3:36 AM   in reply to optimator999

    Why not:

     

    function PS:validatePublishedCollectionName( name )

         if nameInfoLoaded then

              if duplicateName( name ) then

                   return false, "duplicate name"

              else

                   return true

              end

         else

              return false, "Contacting server to check collection name..."

         end

    end

     

    Then, in "start dialog" method, create the task that loads name info from server.

    in "end dialog" method, kill the task, if it doesn't die by itself...

     

    Although a little rough for you, 'twould be smooth as silk for your users.

     

    ?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 25, 2012 5:14 AM   in reply to optimator999

    The only trick is keeping multiple instances of the name checking task from running if user is yanking the plugin manager around and reloading the plugin...

     

    Lightroom does NOT stop tasks from running automatically even if you reload the plugin.

     

    So, make sure you have a shutdown module: LrShutdownPlugin = ... defined in Info.lua - have it set a global shutdown flag that you check in your task.

     

    I mean, this only makes sense if the task is going to have  loops with sleeps and such.... - if it's a one shot and it's done, then there is no opportunity to check the shutdown flag.

     

    Rob

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points