1515class OpenEdxPublicSignal (Signal ):
1616 """
1717 Custom class used to create Open edX events.
18-
19- Arguments:
20- - event_type (str): name of the event.
21- - data (dict): attributes passed to the event.
22- - minor_version (str): version of the event type.
2318 """
2419
2520 def __init__ (self , event_type = None , data = None , minor_version = "0.0" ):
21+ """
22+ Init method for OpenEdxPublicSignal definition class.
23+
24+ Arguments:
25+ event_type (str): name of the event.
26+ data (dict): attributes passed to the event.
27+ minor_version (str): version of the event type.
28+ """
2629 if not event_type or not data :
2730 raise InstantiationException (
2831 event_type = event_type , message = "Missing required argument."
@@ -33,11 +36,14 @@ def __init__(self, event_type=None, data=None, minor_version="0.0"):
3336 super ().__init__ ()
3437
3538 def __repr__ (self ):
39+ """
40+ Represent OpenEdxPublicSignal as a string.
41+ """
3642 return "<OpenEdxPublicSignal: {event_type}>" .format (event_type = self .event_type )
3743
3844 def get_signal_metadata (self ):
3945 """
40- Used to set signal extra metadata when an event is sent.
46+ Get signal extra metadata when an event is sent.
4147
4248 These fields are generated on the fly and are a subset of the Event
4349 Message defined in the OEP-41.
@@ -47,28 +53,28 @@ def get_signal_metadata(self):
4753
4854 def get_current_time ():
4955 """
50- Helper function used to get timestamp when the event ocurred.
56+ Getter function used to get timestamp when the event ocurred.
5157 """
5258 return str (datetime .utcnow ().isoformat ()) + "Z"
5359
5460 def get_source ():
5561 """
56- Helper function used to get logical source of an event.
62+ Getter function used to get logical source of an event.
5763 """
5864 return "openedx/{service}/web" .format (
5965 service = getattr (settings , "SERVICE_VARIANT" , "" )
6066 )
6167
6268 def get_source_host ():
6369 """
64- Helper function used to get physical source of the event.
70+ Getter function used to get physical source of the event.
6571 """
6672 current_request = crum .get_current_request ()
6773 return current_request .get_host () if current_request else None
6874
6975 def get_spec_version ():
7076 """
71- Helper function used to get the Open edX Events version.
77+ Getter function used to get the Open edX Events version.
7278 """
7379 return openedx_events .__version__
7480
@@ -83,31 +89,31 @@ def get_spec_version():
8389
8490 def send_event (self , send_robust = True , ** kwargs ):
8591 """
86- Custom method that sends events to all connected receivers.
92+ Send events to all connected receivers.
8793
88- Used to send events just like Django signals are sent. In addition, runs
89- validations on the arguments sent and generates relevant metadata
90- that can be used for logging or debugging purposes. Besides this
91- behavior, send_event behaves just like the send method.
94+ Used to send events just like Django signals are sent. In addition,
95+ some validations are run on the arguments, and then relevant metadata
96+ that can be used for logging or debugging purposes is generated.
97+ Besides this behavior, send_event behaves just like the send method.
9298
9399 Example usage:
94100
95101 Keyword arguments:
96- - send_robust (bool):
102+ send_robust (bool):
97103
98104 Returns:
99- - list: response of each receiver following the format
105+ list: response of each receiver following the format
100106 [(receiver, response), ... ]
101107
102108 Exceptions raised:
103- - SenderValidationException: raised when there's a mismatch between
109+ SenderValidationException: raised when there's a mismatch between
104110 arguments passed to this method and arguments used to initialize
105111 the event.
106112 """
107113
108114 def validate_sender ():
109115 """
110- Helper method used to run validations over the send arguments.
116+ Run validations over the send arguments.
111117 """
112118 if len (kwargs ) != len (self .init_data ):
113119 raise SenderValidationException (
0 commit comments