Attachment 'label_priority-099-01.patch'

Download

   1 Index: EventCalendar.py
   2 ===================================================================
   3 --- EventCalendar.py	(revision 244)
   4 +++ EventCalendar.py	(working copy)
   5 @@ -200,7 +200,7 @@
   6      page_action = ''
   7      form_vals = {}
   8      events = None
   9 -    labels = None
  10 +    labels = {}
  11  
  12  
  13  class Params:
  14 @@ -239,7 +239,7 @@
  15      
  16      # INITIALIZATION ----------------------------------------
  17      setglobalvalues(macro)
  18 -    getparams(args)
  19 +    getparams(request, args)
  20      
  21      # allowed actions
  22      allowed_action = ['monthly', 'list', 'simple', 'upcoming', 'daily', 'weekly']
  23 @@ -316,7 +316,7 @@
  24  
  25  
  26  
  27 -def getparams(args):
  28 +def getparams(request, args):
  29      # process arguments
  30      
  31      params = {}
  32 @@ -693,7 +693,7 @@
  33      if Params.showpagelist:
  34          source_pages = []
  35      
  36 -        events, cal_events, labels = loadEvents()
  37 +        events, cal_events = loadEvents()
  38      
  39          for eid in events.keys():
  40              event = events[eid]
  41 @@ -810,7 +810,7 @@
  42      html_list_header = cal_listhead()
  43      
  44      # read all the events
  45 -    events, cal_events, labels = loadEvents()
  46 +    events, cal_events = loadEvents()
  47      
  48      # sort events
  49      sorted_eventids = events.keys()
  50 @@ -883,7 +883,7 @@
  51      dateto = u'%04d%02d%02d' % (next_range.year, next_range.month, next_range.day)
  52      
  53      # read all the events (no cache)
  54 -    events, cal_events, labels = loadEvents(datefrom, dateto, 1)
  55 +    events, cal_events = loadEvents(datefrom, dateto, 1)
  56      
  57      nowtime = formattimeobject(Globs.now)
  58      
  59 @@ -1118,11 +1118,10 @@
  60      debug('Loading event information.')
  61      
  62      events = {}
  63 -    labels = {}
  64      cal_events = {}
  65      raw_events = {}
  66      
  67 -    raw_events, labels = loadEventsFromWikiPages()
  68 +    raw_events = loadEventsFromWikiPages()
  69      
  70      # handling cal_events
  71      if datefrom or dateto:
  72 @@ -1418,26 +1417,21 @@
  73          events = raw_events
  74          
  75          # store event list into global variables in order to sort them
  76 -        Globs.events = events
  77 +        Globs.events = raw_events
  78      
  79 -    Globs.labels = labels
  80 -    
  81      debug(u'Total %d events are loaded finally.' % len(events))
  82 -    debug(u'Total %d labels are loaded finally.' % len(labels))
  83 +    debug(u'Total %d labels are loaded finally.' % len(Globs.labels))
  84      
  85 -    return events, cal_events, labels
  86 +    return events, cal_events
  87  
  88  
  89  
  90  def loadEventsFromWikiPages():
  91      
  92      events = {}
  93 -    labels = {}
  94      cached_event_loaded = 0
  95      dirty = 0
  96      
  97 -    eventrecord_list = []
  98 -    labelrecord_list = []
  99      eventpages = []
 100      stored_errmsg = ''
 101      
 102 @@ -1563,8 +1557,16 @@
 103                      cache_labelrecords.update(pickle.dumps(labelrecords, PICKLE_PROTOCOL))
 104                      cache_errmsg.update(pickle.dumps(Globs.errormsg, PICKLE_PROTOCOL))
 105      
 106 -            eventrecord_list.append(eventrecords)
 107 -            labelrecord_list.append(labelrecords)
 108 +            for evtrecord in eventrecords:
 109 +                e_id = evtrecord['id']
 110 +                events[e_id] = evtrecord
 111 +
 112 +            for label in labelrecords:
 113 +                c_id = label['name']
 114 +                if not Globs.labels.has_key(c_id):
 115 +                    Globs.labels[c_id] = label
 116 +                elif label['refer'] !=  Globs.labels[c_id]['refer'] :
 117 +                    stored_errmsg += u'<li>%s\n' % geterrormsg('redefined_label', label['refer'], label['name'])
 118              
 119              stored_errmsg += Globs.errormsg
 120              Globs.errormsg = ''
 121 @@ -1577,7 +1579,7 @@
 122          
 123          try:
 124              events = pickle.loads(cache_events.content())
 125 -            labels = pickle.loads(cache_labels.content())
 126 +            Globs.labels = pickle.loads(cache_labels.content())
 127              stored_errmsg = pickle.loads(cache_errmsglist.content())
 128              
 129              cached_event_loaded = 1
 130 @@ -1586,7 +1588,7 @@
 131              
 132          except (pickle.UnpicklingError, IOError, EOFError, ValueError):
 133              events = {}
 134 -            labels = {}
 135 +            Globs.labels = {}
 136              stored_errmsg = ''
 137              
 138              debug('Picke error at fetching cached events')
 139 @@ -1599,22 +1601,9 @@
 140          for page_name in eventpages:
 141              debug(debug_records[page_name])
 142  
 143 -        for eventrecords in eventrecord_list:
 144 -            for evtrecord in eventrecords:
 145 -                e_id = evtrecord['id']
 146 -                events[e_id] = evtrecord
 147 -        
 148 -        for labelrecords in labelrecord_list:
 149 -            for label in labelrecords:
 150 -                c_id = label['name']
 151 -                if not labels.has_key(c_id):
 152 -                    labels[c_id] = label
 153 -                else:
 154 -                    stored_errmsg += u'<li>%s\n' % geterrormsg('redefined_label', label['refer'], label['name'])
 155 -        
 156          # after generating updated events, update the cache
 157          cache_events.update(pickle.dumps(events, PICKLE_PROTOCOL))
 158 -        cache_labels.update(pickle.dumps(labels, PICKLE_PROTOCOL))
 159 +        cache_labels.update(pickle.dumps(Globs.labels, PICKLE_PROTOCOL))
 160          cache_errmsglist.update(pickle.dumps(stored_errmsg, PICKLE_PROTOCOL))
 161          
 162          debug('Event information is newly built: total %d events' % len(events))
 163 @@ -1623,7 +1612,7 @@
 164      
 165      # end of updating events block    
 166      
 167 -    return events, labels
 168 +    return events
 169      
 170  
 171  
 172 @@ -2037,7 +2026,9 @@
 173      ##################### retrieve startdate
 174      match = pattern_startdate.search(detail)
 175      
 176 -    if match:
 177 +    startdate = ''
 178 +    starttime = ''
 179 +    if match :
 180      
 181          if match.group('startdate'):
 182              passed = 1
 183 @@ -2082,11 +2073,6 @@
 184              
 185              if passed:
 186                  startdate = '%d/%02d/%02d' % (int(startyear), int(startmonth), int(startday))
 187 -            else:
 188 -                startdate = ''
 189 -                
 190 -        else:
 191 -            startdate = ''
 192              
 193          if match.group('starttime'):
 194              passed = 1
 195 @@ -2137,11 +2123,7 @@
 196              
 197              if passed:
 198                  starttime = '%02d:%02d' % (int(starthour), int(startmin))
 199 -            else:
 200 -                starttime = ''
 201          
 202 -        else:
 203 -            starttime = ''
 204              
 205          if not startdate:
 206              raise EventcalError('invalid_start')
 207 @@ -2152,6 +2134,8 @@
 208      ##################### retrieve enddate
 209      match = pattern_enddate.search(detail)
 210      
 211 +    enddate = ''
 212 +    endtime = ''
 213      if match:
 214      
 215          if match.group('enddate'):
 216 @@ -2197,11 +2181,6 @@
 217              
 218              if passed:
 219                  enddate = '%d/%02d/%02d' % (int(endyear), int(endmonth), int(endday))
 220 -            else:
 221 -                enddate = ''
 222 -                
 223 -        else:
 224 -            enddate = ''
 225          
 226          if match.group('endtime'):
 227              passed = 1
 228 @@ -2252,57 +2231,44 @@
 229                  
 230              if passed:
 231                  endtime = '%02d:%02d' % (int(endhour), int(endmin))
 232 -            else:
 233 -                endtime = ''
 234 -                
 235 -        else:
 236 -            endtime = ''
 237  
 238          if not (enddate or endtime):
 239              raise EventcalError('invalid_end')
 240  
 241 -    else:
 242 -        enddate = ''
 243 -        endtime = '' 
 244 +    ##################### retrieve label
 245 +    match = pattern_label.search(detail)
 246 +    
 247 +    label = ''
 248 +    if match:
 249 +        if match.group('name'):
 250 +            label = match.group('name')
 251 +        else:
 252 +            errormsgcode('invalid_label')
 253  
 254 -
 255      ##################### retrieve bgcolor
 256      match = pattern_bgcolor.search(detail)
 257      
 258 +    bgcolor = ''
 259      if match:
 260          if match.group('bgcolor'):
 261              bgcolor = match.group('bgcolor')
 262          else:
 263              errormsgcode('invalid_bgcolor')
 264 -            bgcolor = ''
 265 -            
 266 -    else:
 267 -        bgcolor = ''
 268 +    elif label != '' and Globs.labels:
 269 +        labels = Globs.labels
 270  
 271 -    ##################### retrieve label
 272 -    match = pattern_label.search(detail)
 273 -    
 274 -    if match:
 275 -        if match.group('name'):
 276 -            label = match.group('name')
 277 -        else:
 278 -            errormsgcode('invalid_label')
 279 -            label = ''
 280 -            
 281 -    else:
 282 -        label = ''
 283 +        if labels.has_key(label):
 284 +            bgcolor = labels[label]['bgcolor']
 285  
 286      ##################### retrieve description
 287      match = pattern_description.search(detail)
 288      
 289 +    description = ''
 290      if match:
 291          if match.group('description'):
 292              description = match.group('description')
 293          else:
 294              errormsgcode('empty_description')
 295 -            description = ''
 296 -    else:
 297 -        description = ''
 298          
 299      ##################### retrieve recurrence
 300      match = pattern_recur.search(detail)
 301 @@ -2534,7 +2500,7 @@
 302      dateto = u'%04d%02d06' % (next_month.year, next_month.month)
 303      
 304      # read all the events
 305 -    events, cal_events, labels = loadEvents(datefrom, dateto)
 306 +    events, cal_events = loadEvents(datefrom, dateto)
 307      
 308      #debug(u'  events: %s' % events)
 309      #debug(u'  cal_events: %s' % cal_events)
 310 @@ -2792,7 +2758,7 @@
 311      dateto = u'%04d%02d06' % (next_month.year, next_month.month)
 312      
 313      # read all the events
 314 -    events, cal_events, labels = loadEvents(datefrom, dateto)
 315 +    events, cal_events = loadEvents(datefrom, dateto)
 316      
 317      #debug(u'  events: %s' % events)
 318      #debug(u'  cal_events: %s' % cal_events)
 319 @@ -3023,7 +2989,7 @@
 320      dateto = u'%04d%02d06' % (next_month.year, next_month.month)
 321      
 322      # read all the events
 323 -    events, cal_events, labels = loadEvents(datefrom, dateto)
 324 +    events, cal_events = loadEvents(datefrom, dateto)
 325      
 326      #debug(u'  events: %s' % events)
 327      #debug(u'  cal_events: %s' % cal_events)
 328 @@ -3361,7 +3327,7 @@
 329      dateto = u'%04d%02d06' % (next_month.year, next_month.month)
 330      
 331      # read all the events
 332 -    events, cal_events, labels = loadEvents(datefrom, dateto)
 333 +    events, cal_events = loadEvents(datefrom, dateto)
 334      
 335      maketip_js = []
 336      
 337 @@ -3736,14 +3702,6 @@
 338      description = event['description']
 339      bgcolor = event['bgcolor']
 340      
 341 -    if not bgcolor:
 342 -        if Globs.labels:
 343 -            labels = Globs.labels
 344 -            # for backward compatibility
 345 -            if event.has_key('label'):
 346 -                if labels.has_key(event['label']):
 347 -                    bgcolor = labels[event['label']]['bgcolor']
 348 -    
 349      year, month, day = getdatefield(cur_date)
 350      
 351      if bgcolor:
 352 @@ -3789,13 +3747,6 @@
 353      description = event['description']
 354      bgcolor = event['bgcolor']
 355      
 356 -    if not bgcolor:
 357 -        labels = Globs.labels
 358 -        # for backward compatibility
 359 -        if event.has_key('label'):
 360 -            if labels.has_key(event['label']):
 361 -                bgcolor = labels[event['label']]['bgcolor']
 362 -    
 363      year, month, day = getdatefield(cur_date)
 364      
 365      if bgcolor:
 366 @@ -3840,13 +3791,6 @@
 367      bgcolor = event['bgcolor']
 368      time_len = event['time_len']
 369      
 370 -    if not bgcolor:
 371 -        labels = Globs.labels
 372 -        # for backward compatibility
 373 -        if event.has_key('label'):
 374 -            if labels.has_key(event['label']):
 375 -                bgcolor = labels[event['label']]['bgcolor']
 376 -    
 377      if bgcolor:
 378          bgcolor = 'background-color: %s;' % bgcolor
 379      else:
 380 @@ -3880,13 +3824,6 @@
 381      bgcolor = event['bgcolor']
 382      time_len = event['time_len']
 383      
 384 -    if not bgcolor:
 385 -        labels = Globs.labels
 386 -        # for backward compatibility
 387 -        if event.has_key('label'):
 388 -            if labels.has_key(event['label']):
 389 -                bgcolor = labels[event['label']]['bgcolor']
 390 -    
 391      if bgcolor:
 392          bgcolor = 'background-color: %s;' % bgcolor
 393      else:
 394 @@ -3933,13 +3870,6 @@
 395      
 396      year, month, day = getdatefield(cur_date)
 397      
 398 -    if not bgcolor:
 399 -        labels = Globs.labels
 400 -        # for backward compatibility
 401 -        if event.has_key('label'):
 402 -            if labels.has_key(event['label']):
 403 -                bgcolor = labels[event['label']]['bgcolor']
 404 -    
 405      if bgcolor:
 406          bgcolor = 'background-color: %s;' % bgcolor
 407      else:

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2005-10-31 18:42:02, 65.4 KB) [[attachment:EventCalendar-080.py]]
  • [get | view] (2005-11-22 17:40:26, 55.4 KB) [[attachment:EventCalendar-090.py]]
  • [get | view] (2006-01-15 16:25:08, 57.2 KB) [[attachment:EventCalendar-091.py]]
  • [get | view] (2006-01-17 08:02:06, 75.4 KB) [[attachment:EventCalendar-092.py]]
  • [get | view] (2006-01-18 03:54:33, 75.6 KB) [[attachment:EventCalendar-093.py]]
  • [get | view] (2006-02-25 09:00:17, 74.8 KB) [[attachment:EventCalendar-094-easytime.py]]
  • [get | view] (2006-02-06 04:39:13, 76.2 KB) [[attachment:EventCalendar-094.py]]
  • [get | view] (2006-04-17 13:21:03, 122.7 KB) [[attachment:EventCalendar-096.py]]
  • [get | view] (2006-05-12 15:26:40, 150.6 KB) [[attachment:EventCalendar-098.py]]
  • [get | view] (2008-11-05 16:58:27, 3.2 KB) [[attachment:EventCalendar-099-01.py.patch]]
  • [get | view] (2006-05-23 09:50:33, 152.3 KB) [[attachment:EventCalendar-099.py]]
  • [get | view] (2008-02-14 05:18:57, 1.0 KB) [[attachment:EventCalendar-099.py.patch]]
  • [get | view] (2009-07-15 23:35:13, 151.1 KB) [[attachment:EventCalendar-099a.py]]
  • [get | view] (2013-01-21 02:05:25, 152.4 KB) [[attachment:EventCalendar-099b.py]]
  • [get | view] (2006-11-30 15:51:59, 1.8 KB) [[attachment:defaults-099-01.patch]]
  • [get | view] (2005-10-31 18:35:06, 5.0 KB) [[attachment:eventcal-080.css]]
  • [get | view] (2005-10-31 18:35:01, 11.3 KB) [[attachment:eventcal-080.py]]
  • [get | view] (2005-11-22 17:40:51, 6.8 KB) [[attachment:eventcal-090.css]]
  • [get | view] (2005-11-22 17:40:40, 18.1 KB) [[attachment:eventcal-090.py]]
  • [get | view] (2006-04-17 13:22:09, 8.9 KB) [[attachment:eventcal-096.css]]
  • [get | view] (2006-02-08 02:31:50, 1.4 KB) [[attachment:eventcalendar-094-01.patch]]
  • [get | view] (2006-11-30 15:52:26, 12.2 KB) [[attachment:label_priority-099-01.patch]]
  • [get | view] (2006-11-16 17:06:28, 1.1 KB) [[attachment:pagelinks-099-01.patch]]
  • [get | view] (2006-11-16 17:06:52, 2.9 KB) [[attachment:pagelist-099-01.patch]]
  • [get | view] (2006-03-29 07:37:02, 118.7 KB) [[attachment:snap-daily.jpg]]
  • [get | view] (2006-01-18 03:52:49, 23.2 KB) [[attachment:snap-list.jpg]]
  • [get | view] (2006-01-18 03:52:40, 37.4 KB) [[attachment:snap-monthly.jpg]]
  • [get | view] (2006-03-29 07:35:54, 43.8 KB) [[attachment:snap-simple.jpg]]
  • [get | view] (2006-01-18 03:53:04, 29.4 KB) [[attachment:snap-upcoming.jpg]]
  • [get | view] (2006-03-29 07:36:43, 161.0 KB) [[attachment:snap-weekly.jpg]]
  • [get | view] (2007-06-12 19:51:39, 55.0 KB) [[attachment:time_bug.PNG]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.