blob: f4c7743aba31d991e3fc5c36374af9f576c25df3 [file] [log] [blame]
Scott Baker86e132c2015-02-11 21:38:09 -08001from xos.config import Config
Sapan Bhatia26d40bc2014-05-12 15:28:02 -04002
3try:
4 observer_disabled = Config().observer_disabled
5except:
6 observer_disabled = False
7
8print_once = True
9
10if (not observer_disabled):
11 from .event_manager import EventSender
12
13 def notify_observer(model=None, delete=False, pk=None, model_dict={}):
14 try:
15 if (model and delete):
16 if hasattr(model,"__name__"):
17 modelName = model.__name__
18 else:
19 modelName = model.__class__.__name__
20 EventSender().fire(delete_flag = delete, model = modelName, pk = pk, model_dict=model_dict)
21 else:
22 EventSender().fire()
23 except Exception,e:
24 print "Exception in Observer. This should not disrupt the front end. %s"%str(e)
25
26else:
27 def notify_observer(model=None, delete=False, pk=None, model_dict={}):
28 global print_once
29 if (print_once):
30 print "The observer is disabled"
31 print_once = False
32 return