diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2011-01-14 22:10:35 -0500 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2011-01-14 22:10:35 -0500 |
commit | 61964ded64a8184b7639bf3b9a804061013f56b9 (patch) | |
tree | 2db3cbffd57a6adc492aebc783580e568efcc7cd /askbot/middleware | |
parent | d1777563360257e6e83cdf08d25a5bef99117f05 (diff) | |
download | askbot-61964ded64a8184b7639bf3b9a804061013f56b9.tar.gz askbot-61964ded64a8184b7639bf3b9a804061013f56b9.tar.bz2 askbot-61964ded64a8184b7639bf3b9a804061013f56b9.zip |
small refactoring - moved ViewLog class definition to the search subsystem, because it is part of the search functionality
Diffstat (limited to 'askbot/middleware')
-rw-r--r-- | askbot/middleware/view_log.py | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/askbot/middleware/view_log.py b/askbot/middleware/view_log.py index f6077e12..58815f89 100644 --- a/askbot/middleware/view_log.py +++ b/askbot/middleware/view_log.py @@ -1,7 +1,7 @@ """This module records the site visits by the authenticaded users and heps maintain the state of the search (for all visitors). -Included here is the ViewLogMiddleware and the helper class ViewLog. +Included here is the ViewLogMiddleware """ import logging import datetime @@ -12,44 +12,13 @@ from askbot.views.readers import questions as questions_view from askbot.views.commands import vote from askbot.views.writers import delete_comment, post_comments, retag_question from askbot.views.readers import revisions +from askbot.search.state_manager import ViewLog #todo: the list is getting bigger and bigger - maybe there is a better way to #trigger reset of sarch state? IGNORED_VIEWS = (serve, vote, delete_comment, post_comments, retag_question, revisions) -class ViewLog(object): - """The ViewLog helper obejcts store the trail of the page visits for a - given user. The trail is recorded only up to a certain depth. - - The purpose to record this info is to reset the search state - when the user walks "too far away" from the search page. - - These objects must be modified only in this middlware. - """ - def __init__(self): - self.views = [] - self.depth = 3 #todo maybe move this to const.py - - def get_previous(self, num): - """get a previous record from a certain depth""" - if num > self.depth - 1: - raise Exception("view log depth exceeded") - elif num < 0: - raise Exception("num must be positive") - elif num <= len(self.views) - 1: - return self.views[num] - else: - return None - - def set_current(self, view_name): - """insert a new record""" - self.views.insert(0, view_name) - if len(self.views) > self.depth: - self.views.pop() - - def __str__(self): - return str(self.views) + ' depth=%d' % self.depth class ViewLogMiddleware(object): """ViewLogMiddleware does two things: tracks visits of pages for the |