Changes between Initial Version and Version 1 of Ticket #1745, comment 17


Ignore:
Timestamp:
Jun 24, 2022, 11:36:33 AM (3 years ago)
Author:
Eric Pettersen

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1745, comment 17

    initial v1  
    1 A more generic solution would be to use an import hook.  As a reminder an import hook is called only if the normal import machinery has failed to locate a module and would otherwise throw an !ImportError.  The import hook can look at what module was being requested, determine if that module is provided on the Toolshed, and if it is inform the user that they need to install a particular bundle to carry out their requested operation, bring up the bundle's Toolshed page in the help browser, and raise !CancelOperation to stop the current code execution.  If the module isn't provided by the Toolshed, just carry on and raise ImportError.
     1A more generic solution would be to use an import hook.  As a reminder an import hook is called only if the normal import machinery has failed to locate a module and would otherwise throw an !ImportError.  The import hook can look at what module was being requested, determine if that module is provided on the Toolshed, and if it is inform the user that they need to install a particular bundle to carry out their requested operation, bring up the bundle's Toolshed page in the help browser, and raise !CancelOperation to stop the current code execution.  If the module isn't provided by the Toolshed, just carry on and raise !ImportError.