0

How to call the default implementation of existing app hooks ?

Hi,

The problem is rather simple, under normal circumstances, as I want to override an existing app hook and call the base implementation. Afterwards I need to do some additional book-keeping.

Normally I would derive from the existing implementation, and call the super class' implementation.

How is this supposed to be done using the hook system ?

To make the issue less abstract, let's assume I have to do something after the standard implementation of the scene_operation_tk-nuke did its work.

For obvious reasons, I don't want to copy-paste the code of the base implementation.

Thanks

PS: tank.hook.get_hook_baseclass() doesn't yield the actual base class, but resorts to returning the Hook type. For core hooks, I could write my own using some hooks, I could write my own using some trickery, but doing the same for apps will require some more insight, that is, access to the current environment's app bundle to get the apps location, from there one would have to find the hook directory.

2 comments

  • 0
    Avatar
    Permanently deleted user

    Hey there Sebastian! Good question! We have a special method that let's you fetch the hook baseclass so you can derive from it. You can even set up several levels of inheritance, if you for example wanted to have a custom hook which inherited from a hook located in a framework which in turn derives from the standard hook that comes with an app. Check out the hooks documentation here. The inheritance support is relatively new and we are currently going through our standard apps and making them more "inheritance friendly" to avoid code duplication and making it easy for users to override and extend existing syntax - you may find that the work files app isn't ready for that sort of treatment just yet - we are working on that right now!

  • 0
    Avatar
    Sebastian Thiel

    Thanks for your lighting fast response !

    With the hook value set to `'{self}/scene_operation_tk-nuke.py:scene_operation_tk-nuke'` in the respective environment file, `get_hook_baseclass()` performs as advertised, therefore solving my problem as I can just call the base implementation (it seems to work so far).

    The actual documentation for this kind of multi-inheritance can be found here (for completeness): https://support.shotgunsoftware.com/entries/95442678

    Thank you

Please sign in to leave a comment.