0 Replies Latest reply on Nov 28, 2011 7:46 AM by areohbee

    why won't inherited members be used in export/publish service return tables?

    areohbee Level 5

      In the code/example that followw, SpecialPublish is a sub-class (derived class, extended class...) of BasePublish (using relatively vanilla Lua object-oriented programming methodology).

       

      assert( SpecialPublish.metadataThatTriggersRepublish ~= nil, "not inherited" ) -- it gets past this point, since SpecialPublish inherits metadataThatTriggersRepublish from BasePublish.

       

      SpecialPublish.metadataThatTriggersRepublish = BasePublish.metadataThatTriggersRepublish -- without this it doesn't work (SpecialPublish.metadataThatTriggersRepublish function will otherwise not be called despite being inherited via metatable).

       

      its as if Lightroom is using rawget or "pairs" to get the members and bypassing the metatable or something.

       

      Makes creating hierarchies of export classes not too smooth...

       

      UPDATE: Here's my workaround:

      -- Inherit directly everything from BasePublish that has not been explicitly assigned in this module.

      -- (since Lightroom will not access indirectly inherited members - those only accessible via metatable).

      --

      for k, v in pairs( BasePublish ) do

          if SpecialPublish[k] then

              if not rawget( SpecialPublish, k ) then -- indirectly inherited

                  SpecialPublish[k] = v -- inherit directly

              -- else explicitly assigned.

              end

          -- else private base-class member.

          end

      end

      -- Takes some of the fun out of having base classes but gets the job done.