view MoinMoin/events/ @ 4792:7a826f946da3

Groups2009: wikidicts were refactored. request.dict provides access only to WikiDicts. DictBase class was merged with Dict. Group class was removed. DictDict was merged with GroupDict removing methods related to the group functionality. The cache key for dicts changed from 'dicts_groups' to 'dicts'. wikidicts test was refined to capture new functionality. Changes in the other code to use DictDict.__contains__ instead of has_dict and DictDict.__getitem__ in place of dict.
author Dmitrijs Milajevs <>
date Sun, 07 Jun 2009 16:04:05 +0200
parents de7ca86a9f62
children c54a1ba60873
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - wikidicts notification plugin for event system

    When a Group or Dict page changes, we rescan them and recreate the cache.

    @copyright: 2007 by MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details.

from MoinMoin import log
logging = log.getLogger(__name__)

from MoinMoin import events as ev
from MoinMoin.groups.backends import wiki_group
from MoinMoin import wikidicts

def handle(event):
    # "changed" includes creation, deletion, renamed and copied
    if (isinstance(event, ev.PageChangedEvent) or isinstance(event, ev.PageRenamedEvent) or
        isinstance(event, ev.PageCopiedEvent) or isinstance(event, ev.TrivialPageChangedEvent)):
        cfg = event.request.cfg
        pagename =
        if or \
            return handle_groupsdicts_changed(event)

def handle_groupsdicts_changed(event):
    """ Handles events related to groups and dicts page changes:
        Scans all pages matching the dict / group regex and pickles the
        data to disk.
    request = event.request
    page =

    logging.debug("groupsdicts changed: %r, scan_dicts started", page.page_name)
    del request.dicts
    gd = wikidicts.DictDict(request)
    logging.debug("groupsdicts changed: scan_dicts finished")

    logging.debug("groups changed: %r, update_cache started", page.page_name)
    logging.debug("groups changed: update_cache finished")