Esempio n. 1
0
    class X(mvc.Model):
        def method(self):
            calls.append("during")

        control = mvc.Control("method",
                              before=_control_before,
                              after=_control_after)
Esempio n. 2
0
    class X(mvc.Model):
        def method(self):
            pass

        control = mvc.Control("method").before("before").after("after")

        def before(self, call, notify):
            calls.append("before")

        def after(self, answer, notify):
            calls.append("after")
Esempio n. 3
0
    class X(mvc.Model):
        def method(self):
            calls.append("during")

        control = mvc.Control("method")

        @control.before
        def control(self, call, notify):
            calls.append("before")

        @control.after
        def control(self, call, notify):
            calls.append("after")
Esempio n. 4
0
    class Container(mvc.Structure):
        def __init__(self, name):
            self.name = name
            self.value = None

        def set(self, value):
            self.value = value

        _control_changes = mvc.Control("set",
                                       before="_before_change",
                                       after="_after_change")

        def _before_change(self, call, notify):
            return self.value

        def _after_change(self, answer, notify):
            notify(old=answer.before, new=self.value)

        def __repr__(self):
            return "Container(%r)" % self.name
Esempio n. 5
0
class Counter(mvc.Model):
    def __init__(self):
        self.value = 0

    def increment(self, amount):
        self.value += amount

    def decrement(self, amount):
        self.value -= amount

    _control_change = (
        mvc.Control("increment", "decrement")
        .before("_control_before_change")
        .after("_control_after_change")
    )

    def _control_before_change(self, call, notify):
        return self.value

    def _control_after_change(self, answer, notify):
        notify(old=answer.before, new=self.value)
Esempio n. 6
0
class Counter(mvc.Model):
    def __init__(self):
        self.value = 0

    def increment(self, amount):
        self.value += amount

    def decrement(self, amount):
        self.value -= amount

    _control_change = mvc.Control(
        ["increment", "decrement"],
        before="_control_before_change",
        after="_control_after_change",
    )

    def _control_before_change(self, call, notify):
        return self.value

    def _control_after_change(self, answer, notify):
        notify(old=answer["before"], new=self.value)
Esempio n. 7
0
 class X:
     _control = mvc.Control()
Esempio n. 8
0
    class MyCounter(Counter):

        _added_control = mvc.Control("increment").before("_added_before")

        def _added_before(self, call, notify):
            notify(message="before")
Esempio n. 9
0
 class X:
     _control = mvc.Control("something")