8 Replies Latest reply on Apr 25, 2012 5:14 AM by areohbee

    Publish collection name rejection




      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?



        • 1. Re: Publish collection name rejection
          areohbee Level 6

          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,



          • 2. Re: Publish collection name rejection
            optimator999 Level 1

            Hey Rob! Thanks for the reply. I'm not sure about this, but here's how I solved it: From within updateCollectionSettings when I determine there is a name collision I use the following code to remove the collection:



              local catalog = import "LrApplication".activeCatalog()

                                LrTasks.startAsyncTask( function()

                                catalog:withWriteAccessDo( "Remove invalid collection", function()





            It works. Not sure it's the best solution, but I'm running with it for now.

            • 3. Re: Publish collection name rejection
              areohbee Level 6

              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...

              • 4. Re: Publish collection name rejection
                Don McKee Level 1

                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."



                • 5. Re: Publish collection name rejection
                  optimator999 Level 1

                  I tried to hook into renamePublishedCollection and reparentPublishedCollection but it appears that those methods don't fire when the Published Collection is created. I indeed got them to fire when I'm renaming or reparenting aPublished Collection, but I can't find any other way to prevent the creation of a Published Collection other than in updateCollectionSettings.

                  • 6. Re: Publish collection name rejection
                    areohbee Level 6

                    Why not:


                    function PS:validatePublishedCollectionName( name )

                         if nameInfoLoaded then

                              if duplicateName( name ) then

                                   return false, "duplicate name"


                                   return true



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




                    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.



                    1 person found this helpful
                    • 7. Re: Publish collection name rejection
                      optimator999 Level 1

                      Rob, yes! That's a great way to go. Although, I'll still have to implement the other code (collection appears and then dissapears) because, while I can obtain a list of collections from the service for the user and ensure the the uniqueness among the user's collection, I still must ensure the unqiueness of the name across ALL service users - and then only way to do that is to contact the service with the proposed name.

                      • 8. Re: Publish collection name rejection
                        areohbee Level 6

                        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.



                        1 person found this helpful