handlers.py
changeset 76 cc3ab2c39ded
parent 75 c5ce145fdd70
child 77 4287fb77e312
equal deleted inserted replaced
75:c5ce145fdd70 76:cc3ab2c39ded
   138         calendar        = calendar.Calendar(),
   138         calendar        = calendar.Calendar(),
   139         month           = target.date(),
   139         month           = target.date(),
   140         days            = days,
   140         days            = days,
   141     )
   141     )
   142 
   142 
   143 @preferences.handler(prefs.formatter, prefs.timezone)
   143 @preferences.handler(prefs.formatter, prefs.timezone, prefs.count)
   144 def channel_date (request, channel, date, formatter, timezone) :
   144 def channel_date (request, channel, date, formatter, timezone, count, page=None) :
   145     """
   145     """
   146         Display all log data for the given date
   146         Display all log data for the given date
   147     """
   147     """
   148     
   148 
   149     # fix date timezone
   149     # fix date timezone
   150     date = date.replace(tzinfo=timezone)
   150     date = date.replace(tzinfo=timezone)
   151 
   151 
   152     # get latest events
   152     # get latest events
   153     lines = channel.source.get_date(date)
   153     if page :
       
   154         page, max, lines = channel.source.get_date_paged(date, count, page)
       
   155         
       
   156     else :
       
   157         lines = channel.source.get_date(date)
       
   158         max = None
   154 
   159 
   155     # lines
   160     # lines
   156     lines = formatter.format_html(lines)
   161     lines = formatter.format_html(lines)
   157 
   162 
   158     # render
   163     # render
   159     return templates.render_to_response("channel_date",
   164     return templates.render_to_response("channel_date",
   160         req             = request,
   165         req             = request,
   161         prefs           = request.prefs,
   166         prefs           = request.prefs,
   162         channel         = channel,
   167         channel         = channel,
   163         date            = date,
   168         date            = date,
       
   169         page            = page,
       
   170         count           = count,
       
   171         max             = max,
   164         lines           = lines,
   172         lines           = lines,
   165     )
   173     )
   166 
   174 
   167 @preferences.handler(prefs.formatter, prefs.count)
   175 @preferences.handler(prefs.formatter, prefs.count)
   168 def channel_search (request, channel, formatter, count, q=None, page=1, max=1) :
   176 def channel_search (request, channel, formatter, count, q=None, page=1, max=1) :
   169     """
   177     """
   170         Display the search form for the channel for GET, or do the search for POST.
   178         Display the search form for the channel for GET, or do the search for POST.
   171     """
   179     """
   172 
   180 
   173     # calculate skip offset from page/count
   181     # calculate skip offset from page/count
   174     skip = page * count
   182     skip = (page - 1) * count
   175 
   183 
   176     # got a search query?
   184     # got a search query?
   177     if q :
   185     if q :
   178         try :
   186         try :
   179             # do search
   187             # do search