Changeset e83ea5 in indico for indico/MaKaC/conference.py
- Timestamp:
- 10/18/09 23:29:30 (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, b8c30da8ebdbdcbd675a873997cc3e95f567de49, 4287315ec967a3da168d83963c14001db8487d53
- Children:
- bca298
- Parents:
- 0ff223
- git-author:
- David Martín Clavo <david.martin.clavo@…> (10/18/09 23:17:12)
- git-committer:
- David Martín Clavo <david.martin.clavo@…> (10/18/09 23:29:30)
- File:
-
- 1 edited
-
indico/MaKaC/conference.py (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/conference.py
r9a0611 re83ea5 2683 2683 try: 2684 2684 Logger.get('Conference').error("Exception while notifying the observer %s of of a conference deletion for conference %s: %s"% 2685 (observer.get Name(), self.getId(), str(e)))2685 (observer.getObserverName(), self.getId(), str(e))) 2686 2686 except Exception, e2: 2687 2687 Logger.get('Conference').error("Exception while notifying a conference deletion: %s (origin: %s)"%(str(e2), str(e))) … … 2733 2733 return 2734 2734 self.unindexConf() 2735 self.setStartDate(sDate, check=0, moveEntries=moveEntries,index=False) 2736 self.setEndDate(eDate, check=0, index=False) 2735 2736 self.setStartDate(sDate, check=0, moveEntries = moveEntries, index=False, notifyObservers = False) 2737 self.setEndDate(eDate, check=0, index=False, notifyObservers = False) 2738 2737 2739 self._checkInnerSchedule() 2738 2740 self.indexConf() 2739 2741 self.cleanCategoryCache() 2742 2743 for observer in self.getDateChangeObservers(): 2744 try: 2745 observer.notifyEventDateChanges(oldStartDate, self.getStartDate(), oldEndDate, self.getEndDate()) 2746 except Exception, e: 2747 try: 2748 Logger.get('Conference').error("Exception while notifying the observer %s of a start and end date change from %s - %s to %s - %s for conference %s: %s"% 2749 (observer.getObserverName(), formatDateTime(oldStartDate), formatDateTime(oldEndDate), 2750 formatDateTime(self.getStartDate()), formatDateTime(self.getEndDate()), self.getId(), str(e))) 2751 except Exception, e2: 2752 Logger.get('Conference').error("Exception while notifying a start and end date change: %s (origin: %s)"%(str(e2), str(e))) 2740 2753 2741 2754 def _checkInnerSchedule( self ): 2742 2755 self.getSchedule().checkSanity() 2743 2756 2744 def setStartDate(self, sDate,check=1,moveEntries=0,index=True):2745 """ changes the current conference starting date to the one specified by2746 the parameters"""2757 def setStartDate(self, sDate, check = 1, moveEntries = 0, index = True, notifyObservers = True): 2758 """ Changes the current conference starting date/time to the one specified by the parameters. 2759 """ 2747 2760 if not sDate.tzname(): 2748 2761 raise MaKaCError("date should be timezone aware") … … 2762 2775 oldSdate = self.getStartDate() 2763 2776 diff = sDate - oldSdate 2764 try: 2765 tz = str(sDate.tzinfo) 2766 except: 2767 tz = "Undef" 2777 2768 2778 if index: 2769 2779 self.unindexConf() … … 2786 2796 2787 2797 #if everything went well, we notify the observers that the start date has changed 2788 for observer in self.getDateChangeObservers(): 2789 try: 2790 observer.notifyStartDateChange(oldSdate, sDate) 2791 except Exception, e: 2798 if notifyObservers: 2799 for observer in self.getDateChangeObservers(): 2792 2800 try: 2793 Logger.get('Conference').error("Exception while notifying the observer %s of a start date change from %s to %s for conference %s: %s"% 2794 (observer.getName(), formatDateTime(oldSdate), formatDateTime(sDate), self.getId(), str(e))) 2795 except Exception, e2: 2796 Logger.get('Conference').error("Exception while notifying a start date change: %s (origin: %s)"%(str(e2), str(e))) 2801 observer.notifyEventDateChanges(oldSdate, sDate, None, None) 2802 except Exception, e: 2803 try: 2804 Logger.get('Conference').error("Exception while notifying the observer %s of a start date change from %s to %s for conference %s: %s"% 2805 (observer.getObserverName(), formatDateTime(oldSdate), formatDateTime(sDate), self.getId(), str(e))) 2806 except Exception, e2: 2807 Logger.get('Conference').error("Exception while notifying a start date change: %s (origin: %s)"%(str(e2), str(e))) 2797 2808 2798 2809 … … 2801 2812 raise MaKaCError( _("End date cannot be before the Start date"), _("Event")) 2802 2813 2803 def setStartTime(self, hours=0, minutes=0): 2814 def setStartTime(self, hours=0, minutes=0, notifyObservers = True): 2815 """ Changes the current conference starting time (not date) to the one specified by the parameters. 2816 """ 2817 2804 2818 sdate = self.getStartDate() 2805 2819 self.startDate = datetime( sdate.year, sdate.month, sdate.day, … … 2809 2823 2810 2824 #if everything went well, we notify the observers that the start date has changed 2811 for observer in self.getDateChangeObservers(): 2812 try: 2813 observer.notifyStartDateChange(sdate, self.startDate) 2814 except Exception, e: 2825 if notifyObservers: 2826 for observer in self.getDateChangeObservers(): 2815 2827 try: 2816 Logger.get('Conference').error("Exception while notifying the observer %s of a start date change from %s to %s for conference %s: "% 2817 (observer.getName(), formatDateTime(sdate), formatDateTime(self.startDate), self.getId(), str(e))) 2818 except Exception, e2: 2819 Logger.get('Conference').error("Exception while notifying a start time change: %s (origin: %s)"%(str(e2), str(e))) 2828 observer.notifyEventDateChanges(sdate, self.startDate, None, None) 2829 except Exception, e: 2830 try: 2831 Logger.get('Conference').error("Exception while notifying the observer %s of a start date change from %s to %s for conference %s: "% 2832 (observer.getObserverName(), formatDateTime(sdate), formatDateTime(self.startDate), self.getId(), str(e))) 2833 except Exception, e2: 2834 Logger.get('Conference').error("Exception while notifying a start time change: %s (origin: %s)"%(str(e2), str(e))) 2820 2835 2821 2836 def getStartDate(self): … … 2873 2888 raise MaKaCError(_("Cannot change end date to %s: some entries in the timetable would be outside this date (%s)") % (edate,self.getSchedule().getEntries()[-1].getStartDate()), _("Event")) 2874 2889 2875 def setEndDate(self, eDate, check=1, index=True):2876 """ changes the current conference ending date to the one specified by2877 the parameters"""2890 def setEndDate(self, eDate, check = 1, index = True, notifyObservers = True): 2891 """ Changes the current conference end date/time to the one specified by the parameters. 2892 """ 2878 2893 if not eDate.tzname(): 2879 2894 raise MaKaCError("date should be timezone aware") … … 2896 2911 2897 2912 #if everything went well, we notify the observers that the start date has changed 2898 for observer in self.getDateChangeObservers(): 2899 try: 2900 observer.notifyEndDateChange(oldEdate, eDate) 2901 except Exception, e: 2913 if notifyObservers: 2914 for observer in self.getDateChangeObservers(): 2902 2915 try: 2903 Logger.get('Conference').error("Exception while notifying the observer %s of a end date change from %s to %s for conference %s: "% 2904 (observer.getName(), formatDateTime(oldEdate), formatDateTime(eDate), self.getId(), str(e))) 2905 except Exception, e2: 2906 Logger.get('Conference').error("Exception while notifying a end date change: %s (origin: %s)"%(str(e2), str(e))) 2907 2908 def setEndTime(self, hours=0, minutes=0): 2916 observer.notifyEventDateChanges(None, None, oldEdate, eDate) 2917 except Exception, e: 2918 try: 2919 Logger.get('Conference').error("Exception while notifying the observer %s of a end date change from %s to %s for conference %s: "% 2920 (observer.getObserverName(), formatDateTime(oldEdate), formatDateTime(eDate), self.getId(), str(e))) 2921 except Exception, e2: 2922 Logger.get('Conference').error("Exception while notifying a end date change: %s (origin: %s)"%(str(e2), str(e))) 2923 2924 def setEndTime(self, hours = 0, minutes = 0, notifyObservers = True): 2925 """ Changes the current conference end time (not date) to the one specified by the parameters. 2926 """ 2909 2927 edate = self.getEndDate() 2910 self.endDate = datetime( edate.year, edate.month, edate.day, \ 2911 int(hours), int(minutes) ) 2928 self.endDate = datetime( edate.year, edate.month, edate.day, int(hours), int(minutes) ) 2912 2929 self.verifyEndDate(self.endDate) 2913 2930 self.notifyModification() 2914 2931 2915 2932 #if everything went well, we notify the observers that the start date has changed 2916 for observer in self.getDateChangeObservers(): 2917 try: 2918 observer.notifyEndDateChange(edate, self.endDate) 2919 except Exception, e: 2933 if notifyObservers: 2934 for observer in self.getDateChangeObservers(): 2920 2935 try: 2921 Logger.get('Conference').error("Exception while notifying the observer %s of a end timet change from %s to %s for conference %s: "% 2922 (observer.getName(), formatDateTime(edate), formatDateTime(self.endDate), self.getId(), str(e))) 2923 except Exception, e2: 2924 Logger.get('Conference').error("Exception while notifying a end time change: %s (origin: %s)"%(str(e2), str(e))) 2936 observer.notifyEventDateChanges(None, None, edate, self.endDate) 2937 except Exception, e: 2938 try: 2939 Logger.get('Conference').error("Exception while notifying the observer %s of a end timet change from %s to %s for conference %s: "% 2940 (observer.getObserverName(), formatDateTime(edate), formatDateTime(self.endDate), self.getId(), str(e))) 2941 except Exception, e2: 2942 Logger.get('Conference').error("Exception while notifying a end time change: %s (origin: %s)"%(str(e2), str(e))) 2925 2943 2926 2944 def getEndDate(self): … … 3043 3061 try: 3044 3062 Logger.get('Conference').error("Exception while notifying the observer %s of of a conference title change for conference %s: %s"% 3045 (observer.get Name(), self.getId(), str(e)))3063 (observer.getObserverName(), self.getId(), str(e))) 3046 3064 except Exception, e2: 3047 3065 Logger.get('Conference').error("Exception while notifying a conference title change: %s (origin: %s)"%(str(e2), str(e))) … … 4911 4929 return None 4912 4930 4913 class TitleChangeObserver(object):4914 """ Base class for objects who want to be notified of a Conference object being deleted.4915 Inheriting classes have to implement the notifyDeletion method, and probably the __init__ method too.4931 class Observer(object): 4932 """ Base class for Observer objects. 4933 Provides the getObserverName method (used when writing info to the Indico log) 4916 4934 """ 4917 4935 def getObserverName(self): 4918 name = "' title change observer of class" + self.__class__.__name__4919 try: 4920 conf erence = self.getConference()4921 name = name + " of conference " + conference.getId()4936 name = "'Observer of class" + self.__class__.__name__ 4937 try: 4938 conf = self.getOwner() 4939 name = name + " of event " + conf.getId() + "'" 4922 4940 except AttributeError: 4923 4941 pass 4924 4942 return name 4943 4944 class TitleChangeObserver(Observer): 4945 """ Base class for objects who want to be notified of a Conference object being deleted. 4946 Inheriting classes have to implement the notifyTitleChange method, and probably the __init__ method too. 4947 """ 4925 4948 4926 4949 def notifyTitleChange(self, oldTitle, newTitle): … … 4930 4953 raise MaKaCError("Class " + str(self.__class__.__name__) + " did not implement method notifyTitleChange") 4931 4954 4932 class DateChangeObserver( object):4955 class DateChangeObserver(Observer): 4933 4956 """ Base class for objects who want to be notified of a change in the start date / end date 4934 4957 of an object (for example a Conference object). … … 4936 4959 and probably the __init__ method too. 4937 4960 """ 4938 def getObserverName(self): 4939 name = "'date observer of class" + self.__class__.__name__ 4940 try: 4941 conference = self.getConference() 4942 name = name + " of conference " + conference.getId() 4943 except AttributeError: 4944 pass 4945 return name 4946 4947 def notifyStartDateChange(self, oldStartDate, newStartDate): 4961 4962 def notifyEventDateChanges(self, oldStartDate = None, newStartDate = None, oldEndDate = None, newEndDate = None): 4948 4963 """ To be implemented by inheriting classes 4949 Notifies the observer that the start date of the object it is attached to has changed 4964 Notifies the observer that the start and / or end dates of the object it is attached to has changed. 4965 If the observer finds any problems during whatever he needs to do as a consequence of 4966 the event dates changing, he should write strings describing the problems 4967 in the 'dateChangeNotificationProblems' context variable (which is a list of strings). 4950 4968 """ 4951 4969 raise MaKaCError("Class " + str(self.__class__.__name__) + " did not implement method notifyStartDateChange") 4952 4970 4953 def notifyEndDateChange(self, oldEndDate, newEndDate):4954 """ To be implemented by inheriting classes4955 Notifies the observer that the end date of the object it is attached to has changed4956 """4957 raise MaKaCError("Class " + str(self.__class__.__name__) + " did not implement method notifyStartDateChange")4958 4959 4971 def notifyTimezoneChange(self, oldTimezone, newTimezone): 4960 """ To be implemented by inheriting classes 4961 Notifies the observer that the end date of the object it is attached to has changed 4972 """ To be implemented by inheriting classes. 4973 Notifies the observer that the end date of the object it is attached to has changed. 4974 This method has to return a list of strings describing problems encountered during 4975 whatever the DateChangeObserver object does as a consequence of the notification. 4976 If there are no problems, the DateChangeObserver should return an empty list. 4962 4977 """ 4963 4978 raise MaKaCError("Class " + str(self.__class__.__name__) + " did not implement method notifyTimezoneChange") 4964 4979 4965 4980 4966 class DeleteObserver( object):4981 class DeleteObserver(Observer): 4967 4982 """ Base class for objects who want to be notified of a Conference object being deleted. 4968 4983 Inheriting classes have to implement the notifyDeletion method, and probably the __init__ method too. 4969 4984 """ 4970 def getObserverName(self):4971 name = "'delete observer of class" + self.__class__.__name__4972 try:4973 conference = self.getConference()4974 name = name + " of conference " + conference.getId()4975 except AttributeError:4976 pass4977 return name4978 4979 4985 def notifyDeletion(self): 4980 4986 """ To be implemented by inheriting classes
Note: See TracChangeset
for help on using the changeset viewer.
