web/application.py
branchstable
changeset 5325 f1c660e1169e
parent 5283 9ad0eaa09d34
child 5326 0d9054eb3bd1
equal deleted inserted replaced
5324:449cc4fa9c42 5325:f1c660e1169e
    41             self.cleanup_session_time = (vreg.config['cleanup-session-time'] or 1440) * 60
    41             self.cleanup_session_time = (vreg.config['cleanup-session-time'] or 1440) * 60
    42             assert self.cleanup_session_time > 0
    42             assert self.cleanup_session_time > 0
    43         self.cleanup_anon_session_time = (vreg.config['cleanup-anonymous-session-time'] or 5) * 60
    43         self.cleanup_anon_session_time = (vreg.config['cleanup-anonymous-session-time'] or 5) * 60
    44         assert self.cleanup_anon_session_time > 0
    44         assert self.cleanup_anon_session_time > 0
    45         self.authmanager = vreg['components'].select('authmanager', vreg=vreg)
    45         self.authmanager = vreg['components'].select('authmanager', vreg=vreg)
       
    46         if vreg.config.anonymous_user() is not None:
       
    47             self.clean_sessions_interval = min(
       
    48                 5 * 60,
       
    49                 self.cleanup_session_time / 2.,
       
    50                 self.cleanup_anon_session_time / 2.)
       
    51         else:
       
    52             self.clean_sessions_interval = min(
       
    53                 5 * 60,
       
    54                 self.cleanup_session_time / 2.)
    46 
    55 
    47     def clean_sessions(self):
    56     def clean_sessions(self):
    48         """cleanup sessions which has not been unused since a given amount of
    57         """cleanup sessions which has not been unused since a given amount of
    49         time. Return the number of sessions which have been closed.
    58         time. Return the number of sessions which have been closed.
    50         """
    59         """
   135         self.session_manager = self.vreg['components'].select('sessionmanager',
   144         self.session_manager = self.vreg['components'].select('sessionmanager',
   136                                                               vreg=self.vreg)
   145                                                               vreg=self.vreg)
   137         self.session_manager.restore_data(data)
   146         self.session_manager.restore_data(data)
   138         global SESSION_MANAGER
   147         global SESSION_MANAGER
   139         SESSION_MANAGER = self.session_manager
   148         SESSION_MANAGER = self.session_manager
       
   149 
       
   150     @property
       
   151     def clean_sessions_interval(self):
       
   152         return self.session_manager.clean_sessions_interval
   140 
   153 
   141     def clean_sessions(self):
   154     def clean_sessions(self):
   142         """cleanup sessions which has not been unused since a given amount of
   155         """cleanup sessions which has not been unused since a given amount of
   143         time
   156         time
   144         """
   157         """