<commit_before>#coding:utf-8
'''
File: controller.py
Author: <NAME>
Description:
'''

from m3.ui import actions as m3_actions
from objectpack import observer


# Наблюдатель
obs = observer.Observer()


action_controller = observer.ObservableController(obs, "/actions")


@obs.subscribe
class Listener(object):

    listen = ['foo']

    def after(self, request, context, response):
        # подмена заголовка окна
        response.data.title = u'Му-ха-ха!'<commit_msg>Демо-проект теперь имеет логируемый контроллер. Добавлен слушатель, модифицирующий отображение объектов в BandedColumnsPack<commit_after>#coding:utf-8
'''
File: controller.py
Author: <NAME>
Description:
'''

from m3.ui import actions as m3_actions
from objectpack import observer


def logger(msg):
    print "Observer: %s" % msg

# Наблюдатель
obs = observer.Observer(logger=logger, verbose_level=observer.Observer.LOG_MORE)


action_controller = observer.ObservableController(obs, "/actions")


@obs.subscribe
class Listener(object):

    listen = ['foo']

    def after(self, request, context, response):
        # подмена заголовка окна
        response.data.title = u'Му-ха-ха! (%s)' % self.action.__class__.__name__


@obs.subscribe
class StarToHash(object):

    listen = ['fakemodel/.*']

    def prepare_obj(self, obj):
        if obj.get('field1', None) == u'*':
            obj['field1'] = '#'
        return obj
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.005747126436781609, 'mean_word_length': 4.083941605839416, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3944867', 'n_tokens_mistral': 476, 'n_tokens_neox': 481, 'n_words': 108}