'Fix up a ZCA component registry that is not a
pyramid.registry.Registry by adding analogues of ``has_listeners``,
``notify``, ``queryAdapterOrSelf``, and ``registerSelfAdapter``
through monkey-patching.'

def _fix_registry(self):

    _registry = self.registry
    if (not hasattr(_registry, 'notify')):
        def notify(*events):
            [_ for _ in _registry.subscribers(events, None)]
        _registry.notify = notify
    if (not hasattr(_registry, 'has_listeners')):
        _registry.has_listeners = True
    if (not hasattr(_registry, 'queryAdapterOrSelf')):
        def queryAdapterOrSelf(object, interface, default=None):
            if (not interface.providedBy(object)):
                return _registry.queryAdapter(object, interface, default=default)
            return object
        _registry.queryAdapterOrSelf = queryAdapterOrSelf
    if (not hasattr(_registry, 'registerSelfAdapter')):
        def registerSelfAdapter(required=None, provided=None, name=empty, info=empty, event=True):
            return _registry.registerAdapter((lambda x: x), required=required, provided=provided, name=name, info=info, event=event)
        _registry.registerSelfAdapter = registerSelfAdapter
    if (not hasattr(_registry, '_lock')):
        _registry._lock = threading.Lock()
    if (not hasattr(_registry, '_clear_view_lookup_cache')):
        def _clear_view_lookup_cache():
            _registry._view_lookup_cache = {}
        _registry._clear_view_lookup_cache = _clear_view_lookup_cache
