Changeset 119b7d in indico
- Timestamp:
- 10/18/09 23:31:20 (4 years ago)
- Branches:
- master, burotel, hello-world-walkthrough, ipv6, new-webex, prov-dual-interface, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
- Children:
- f4ad5a
- Parents:
- 498147
- git-author:
- David Martín Clavo <david.martin.clavo@…> (10/07/09 09:49:13)
- git-committer:
- David Martín Clavo <david.martin.clavo@…> (10/18/09 23:31:20)
- Location:
- indico/MaKaC
- Files:
-
- 2 edited
-
conference.py (modified) (14 diffs)
-
plugins/Collaboration/base.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/conference.py
re83ea5 r119b7d 2008 2008 self._sortUrlTag = "" 2009 2009 2010 self._titleChangeObservers = [] 2011 self._dateChangeObservers = [] 2012 self._deleteObservers = [] 2010 self._observers = [] 2013 2011 2014 2012 if PluginsHolder().hasPluginType("Collaboration"): … … 2676 2674 """deletes the conference from the system. 2677 2675 """ 2678 #we notify the observers that the conference 2679 for observer in self.get DeleteObservers():2676 #we notify the observers that the conference has been deleted 2677 for observer in self.getObservers(): 2680 2678 try: 2681 2679 observer.notifyDeletion() … … 2707 2705 indexes.IndexesHolder().getById("OAIPrivateConferenceModificationDate").unindexConference(self) 2708 2706 2709 def getDeleteObservers(self):2710 if not hasattr(self, "_deleteObservers"):2711 self._deleteObservers = []2712 return self._deleteObservers2713 2714 def addDeleteObserver(self, observer):2715 self.getDeleteObservers().append(observer)2716 self._p_changed=12717 2718 def removeDeleteObserver(self, observer):2719 self.getDeleteObservers().remove(observer)2720 self._p_changed=12721 2722 2723 2724 2707 def getConference( self ): 2725 2708 return self 2709 2710 def getObservers(self): 2711 if not hasattr(self, "_observers"): 2712 self._observers = [] 2713 return self._observers 2714 2715 def addObserver(self, observer): 2716 self.getObservers().append(observer) 2717 self._p_changed=1 2718 2719 def removeObserver(self, observer): 2720 self.getObservers().remove(observer) 2721 self._p_changed=1 2726 2722 2727 2723 def setDates( self, sDate, eDate=None, check=1, moveEntries=1 ): … … 2741 2737 self.cleanCategoryCache() 2742 2738 2743 for observer in self.get DateChangeObservers():2739 for observer in self.getObservers(): 2744 2740 try: 2745 2741 observer.notifyEventDateChanges(oldStartDate, self.getStartDate(), oldEndDate, self.getEndDate()) … … 2797 2793 #if everything went well, we notify the observers that the start date has changed 2798 2794 if notifyObservers: 2799 for observer in self.get DateChangeObservers():2795 for observer in self.getObservers(): 2800 2796 try: 2801 2797 observer.notifyEventDateChanges(oldSdate, sDate, None, None) … … 2824 2820 #if everything went well, we notify the observers that the start date has changed 2825 2821 if notifyObservers: 2826 for observer in self.get DateChangeObservers():2822 for observer in self.getObservers(): 2827 2823 try: 2828 2824 observer.notifyEventDateChanges(sdate, self.startDate, None, None) … … 2912 2908 #if everything went well, we notify the observers that the start date has changed 2913 2909 if notifyObservers: 2914 for observer in self.get DateChangeObservers():2910 for observer in self.getObservers(): 2915 2911 try: 2916 2912 observer.notifyEventDateChanges(None, None, oldEdate, eDate) … … 2932 2928 #if everything went well, we notify the observers that the start date has changed 2933 2929 if notifyObservers: 2934 for observer in self.get DateChangeObservers():2930 for observer in self.getObservers(): 2935 2931 try: 2936 2932 observer.notifyEventDateChanges(None, None, edate, self.endDate) … … 2962 2958 ################################## 2963 2959 2964 def getDateChangeObservers(self):2965 if not hasattr(self, "_dateChangeObservers"):2966 self._dateChangeObservers = []2967 return self._dateChangeObservers2968 2969 def addDateChangeObserver(self, observer):2970 self.getDateChangeObservers().append(observer)2971 self._p_changed=12972 2973 def removeDateChangeObserver(self, observer):2974 self.getDateChangeObservers().remove(observer)2975 self._p_changed=12976 2977 2960 def setScreenEndDate(self, date): 2978 2961 if date == self.getEndDate(): … … 3008 2991 oldTimezone = self.timezone 3009 2992 self.timezone = tz 3010 for observer in self.getDateChangeObservers(): 3011 observer.notifyTimezoneChange(oldTimezone, tz) 2993 2994 for observer in self.getObservers(): 2995 try: 2996 observer.notifyTimezoneChange(oldTimezone, tz) 2997 except Exception, e: 2998 try: 2999 Logger.get('Conference').error("Exception while notifying the observer %s of a timezone change from %s to %s for conference %s: "% 3000 (observer.getObserverName(), str(oldTimezone), str(tz), self.getId(), str(e))) 3001 except Exception, e2: 3002 Logger.get('Conference').error("Exception while notifying a timezone change: %s (origin: %s)"%(str(e2), str(e))) 3012 3003 3013 3004 def getTimezone(self): … … 3052 3043 def setTitle(self, title): 3053 3044 """changes the current title of the conference to the one specified""" 3045 oldTitle = self.title 3054 3046 3047 self.title = title 3048 self.cleanCategoryCache() 3049 self.notifyModification() 3055 3050 3056 3051 #we notify the observers that the conference's title has changed 3057 for observer in self.get TitleChangeObservers():3052 for observer in self.getObservers(): 3058 3053 try: 3059 observer.notifyTitleChange( self.title, title)3054 observer.notifyTitleChange(oldTitle, title) 3060 3055 except Exception, e: 3061 3056 try: … … 3064 3059 except Exception, e2: 3065 3060 Logger.get('Conference').error("Exception while notifying a conference title change: %s (origin: %s)"%(str(e2), str(e))) 3066 3067 self.title = title3068 self.cleanCategoryCache()3069 self.notifyModification()3070 3071 def getTitleChangeObservers(self):3072 if not hasattr(self, "_titleChangeObservers"):3073 self._titleChangeObservers = []3074 return self._titleChangeObservers3075 3076 def addTitleChangeObserver(self, observer):3077 self.getTitleChangeObservers().append(observer)3078 self._p_changed=13079 3080 def removeTitleChangeObserver(self, observer):3081 self.getTitleChangeObservers().remove(observer)3082 self._p_changed=13083 3061 3084 3062 def getDescription(self): … … 4931 4909 class Observer(object): 4932 4910 """ Base class for Observer objects. 4933 Provides the getObserverName method (used when writing info to the Indico log) 4911 Inheriting classes should overload the following boolean class attributes: 4912 _shouldBeTitleNotified 4913 _shouldBeDateChangeNotified 4914 _shouldBeDeletionNotified 4915 And set them to True if they want to be notified of the corresponding event. 4916 In that case, they also have to implement the corresponding methods: 4917 _notifyTitleChange (for title notification) 4918 _notifyEventDateChanges and _notifyTimezoneChange (for date / timezone notification) 4919 _notifyDeletion (for deletion notification). 4920 The interface for those methods is also specified in this class. If the corresponding 4921 class attribute is set to False but the method is not implemented, an exception will be thrown. 4934 4922 """ 4923 _shouldBeTitleNotified = False 4924 _shouldBeDateChangeNotified = False 4925 _shouldBeDeletionNotified = False 4926 4935 4927 def getObserverName(self): 4936 4928 name = "'Observer of class" + self.__class__.__name__ … … 4941 4933 pass 4942 4934 return name 4935 4936 def notifyTitleChange(self, oldTitle, newTitle): 4937 if self._shouldBeTitleNotified: 4938 self._notifyTitleChange(oldTitle, newTitle) 4939 4940 def notifyEventDateChanges(self, oldStartDate = None, newStartDate = None, oldEndDate = None, newEndDate = None): 4941 if self._shouldBeDateChangeNotified: 4942 self._notifyEventDateChanges(oldStartDate, newStartDate, oldEndDate, newEndDate) 4943 4944 def notifyTimezoneChange(self, oldTimezone, newTimezone): 4945 if self._shouldBeDateChangeNotified: 4946 self._notifyTimezoneChange(oldTimezone, newTimezone) 4947 4948 def notifyDeletion(self): 4949 if self._shouldBeDeletionNotified: 4950 self._notifyDeletion() 4951 4952 def _notifyTitleChange(self, oldTitle, newTitle): 4953 """ To be implemented by inheriting classes 4954 Notifies the observer that the Conference object's title has changed 4955 """ 4956 raise MaKaCError("Class " + str(self.__class__.__name__) + " did not implement method _notifyTitleChange") 4957 4958 def _notifyEventDateChanges(self, oldStartDate, newStartDate, oldEndDate, newEndDate): 4959 """ To be implemented by inheriting classes 4960 Notifies the observer that the start and / or end dates of the object it is attached to has changed. 4961 If the observer finds any problems during whatever he needs to do as a consequence of 4962 the event dates changing, he should write strings describing the problems 4963 in the 'dateChangeNotificationProblems' context variable (which is a list of strings). 4964 """ 4965 raise MaKaCError("Class " + str(self.__class__.__name__) + " did not implement method notifyStartDateChange") 4966 4967 def _notifyTimezoneChange(self, oldTimezone, newTimezone): 4968 """ To be implemented by inheriting classes. 4969 Notifies the observer that the end date of the object it is attached to has changed. 4970 This method has to return a list of strings describing problems encountered during 4971 whatever the DateChangeObserver object does as a consequence of the notification. 4972 If there are no problems, the DateChangeObserver should return an empty list. 4973 """ 4974 raise MaKaCError("Class " + str(self.__class__.__name__) + " did not implement method notifyTimezoneChange") 4975 4976 def _notifyDeletion(self): 4977 """ To be implemented by inheriting classes 4978 Notifies the observer that the Conference object it is attached to has been deleted 4979 """ 4980 raise MaKaCError("Class " + str(self.__class__.__name__) + " did not implement method notifyDeletion") 4943 4981 4944 4982 class TitleChangeObserver(Observer): -
indico/MaKaC/plugins/Collaboration/base.py
r34a768 r119b7d 47 47 """ 48 48 49 _shouldBeTitleNotified = True 50 _shouldBeDateChangeNotified = True 51 _shouldBeDeletionNotified = True 52 49 53 def __init__(self, conf): 50 54 """ Constructor for the CSBookingManager class. … … 65 69 self._managers = {} 66 70 67 #we register as a date change observer of the conference 68 self._conf.addTitleChangeObserver(self) 69 70 #we register as a date change observer of the conference 71 self._conf.addDateChangeObserver(self) 72 73 #we register as a delete observer of the conference 74 self._conf.addDeleteObserver(self) 71 #we register as an observer of the conference 72 self._conf.addObserver(self) 75 73 76 74 def getOwner(self): … … 80 78 81 79 def restoreAsObserver(self): 82 if not self in self._conf.getTitleChangeObservers(): 83 self._conf.addTitleChangeObserver(self) 84 if not self in self._conf.getDateChangeObservers(): 85 self._conf.addDateChangeObserver(self) 86 if not self in self._conf.getDeleteObservers(): 87 self._conf.addDeleteObserver(self) 80 if not self in self._conf.getObservers(): 81 self._conf.addObserver(self) 88 82 89 83 def isCSAllowed(self):
Note: See TracChangeset
for help on using the changeset viewer.
