0

Custom hook without overriding the core hook?

Hi, I want to know if it's possible to keep a default hook and add a custom hook without overriding the default.  From what I read, it's not possible, but maybe I missed something. Example: I want to keep the folder creation hook but just add a small behavior with a custom hook.  My only choice is to copy the default hook and add my code in it, right?

Thanks!

4 comments

  • 0
    Avatar
    Permanently deleted user

    Hello!

    Yes, at the moment we don't support a way to extend or augment the default hooks, so you have to override the whole thing! We try to keep most hooks light weight and atomic, however some hooks are a bit more complex - for example the folder creation hook!

    What sort of behaviour were you thinking for a default hook override? A way of deriving from the default hook somehow? Or a way of more easily segmenting the hook into separate pieces and then overriding one of this pieces?

    Thanks!

  • 0
    Avatar
    Mathieu Leblanc

    I didn't know that hook were supposed to be atomic and simple, it's good to know and I like that. If we continue with this philosophy, deriving is not a good idea. The other option is maybe to support multiple class per hook? I see that like a C# event.

    ex: I really like the default publish in the shot but I just want to add validation for our internal scene standard that pop a message box if something is wrong.

    tk-multi-publish:
    hook_copy_file: default
    hook_post_publish: default
    hook_primary_pre_publish: default, validate_scene_name
    hook_primary_publish: default
    hook_scan_scene: default
    hook_secondary_pre_publish: default
    hook_secondary_publish: default
    hook_thumbnail: default

    I don't want to copy all the hook_primary_pre_publish and add my code to it. And if the default hook_primary_pre_publish change, I need to remember it and thi to update my copied version.

    For the creation folder, I'm not sure how we could do it since there's no config file

     

  • 0
    Avatar
    Permanently deleted user

    That's a really interesting approach! I will brainstorm a bit with the engineers and see what they think! I suspect this event-style approach may work well for some hook types but perhaps be less suitable for others. 

    One thing I thought about was to be able to access parts of the default hook from inside of the overridden hook. Perhaps something as simple as public methods on the default hook class - and these methods are part of an API interface which we (or any other app developer) will maintain and keep backwards compatible. Curious to hear your thoughts about that approach!

  • 0
    Avatar
    Mathieu Leblanc

    Yes public method access from the default hook is a good idea.  It's simple and it replace the deriving idea

Please sign in to leave a comment.