streamfield_tools/registry.py
def find_blocks():
    """
    Auto-discover INSTALLED_APPS registered_blocks.py modules and fail
    silently when not present. This forces an import on them thereby
    registering their blocks.

    This is a near 1-to-1 copy of how django's admin application registers
    models.
    """

    for app in settings.INSTALLED_APPS:
        mod = import_module(app)
        # Attempt to import the app's sizedimage module.
        try:
            before_import_block_registry = copy.copy(
                block_registry._registry
            )
            import_module('{}.registered_blocks'.format(app))
        except:
            # Reset the block_registry to the state before the last
            # import as this import will have to reoccur on the next request
            # and this could raise NotRegistered and AlreadyRegistered
            # exceptions (see django ticket #8245).
            block_registry._registry = before_import_block_registry

            # Decide whether to bubble up this error. If the app just
            # doesn't have a stuff module, we can ignore the error
            # attempting to import it, otherwise we want it to bubble up.
            if module_has_submodule(mod, 'registered_blocks'):
                raise
def find_blocks():
    for app in settings.INSTALLED_APPS:
        mod = import_module(app)
        # Attempt to import the app's sizedimage module.
        try:
            before_import_block_registry = copy.copy(
                block_registry._registry
            )
            import_module('{}.registered_blocks'.format(app))
        except:
            # Reset the block_registry to the state before the last
            # import as this import will have to reoccur on the next request
            # and this could raise NotRegistered and AlreadyRegistered
            # exceptions (see django ticket #8245).
            block_registry._registry = before_import_block_registry

            # Decide whether to bubble up this error. If the app just
            # doesn't have a stuff module, we can ignore the error
            # attempting to import it, otherwise we want it to bubble up.
            if module_has_submodule(mod, 'registered_blocks'):
                raise
def find_blocks ( ) : for app in settings . INSTALLED_APPS : mod = import_module ( app ) # Attempt to import the app's sizedimage module. try : before_import_block_registry = copy . copy ( block_registry . _registry ) import_module ( '{}.registered_blocks' . format ( app ) ) except : # Reset the block_registry to the state before the last # import as this import will have to reoccur on the next request # and this could raise NotRegistered and AlreadyRegistered # exceptions (see django ticket #8245). block_registry . _registry = before_import_block_registry # Decide whether to bubble up this error. If the app just # doesn't have a stuff module, we can ignore the error # attempting to import it, otherwise we want it to bubble up. if module_has_submodule ( mod , 'registered_blocks' ) : raise
Auto-discover INSTALLED_APPS registered_blocks.py modules and fail
    silently when not present. This forces an import on them thereby
    registering their blocks.

    This is a near 1-to-1 copy of how django's admin application registers
    models.
Auto - discover INSTALLED_APPS registered_blocks . py modules and fail silently when not present . This forces an import on them thereby registering their blocks .