~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/longpoll/interfaces.py

  • Committer: Jelmer Vernooij
  • Date: 2011-09-21 14:28:02 UTC
  • mfrom: (14006 devel)
  • mto: This revision was merged to the branch mainline in revision 14010.
  • Revision ID: jelmer@canonical.com-20110921142802-7ggkc204igsy532w
MergeĀ lp:launchpad

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
__all__ = [
8
8
    "ILongPollEvent",
9
9
    "ILongPollSubscriber",
 
10
    "long_poll_event",
10
11
    ]
11
12
 
12
 
 
 
13
from zope.component import adapter
13
14
from zope.interface import (
14
15
    Attribute,
 
16
    classImplements,
15
17
    Interface,
16
18
    )
17
19
 
49
51
 
50
52
        :type event: ILongPollEvent
51
53
        """
 
54
 
 
55
 
 
56
def long_poll_event(source_spec, event_spec=basestring):
 
57
    """Class decorator to declare an `ILongPollEvent`.
 
58
 
 
59
    :param source_spec: An interface or other specification understood by
 
60
        `zope.component` (a plain class can be passed too) that defines the
 
61
        source of an event. `IJob` or `storm.base.Storm` for example.
 
62
    :param source_event: An interface or other specification understood by
 
63
        `zope.component`. The exact use here is left to implementers. By
 
64
        default it is `basestring` so that terms like "modified" or
 
65
        "lifecycle" can be used when looking up the event, but it could also
 
66
        be `IObjectModifiedEvent`. The dominant use case is evolving.
 
67
    """
 
68
    declare_adapter = adapter(source_spec, event_spec)
 
69
 
 
70
    def declare_event(cls):
 
71
        classImplements(cls, ILongPollEvent)
 
72
        declare_adapter(cls)
 
73
        return cls
 
74
 
 
75
    return declare_event