示例#1
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        #send the site_visited signal for the authenticated users
        if request.user.is_authenticated():
            signals.site_visited.send(
                None,  #this signal has no sender
                user=request.user,
                timestamp=datetime.datetime.now())

        #remaining stuff is for the search state
        if view_func == questions_view:
            view_str = 'questions'
        elif view_func in IGNORED_VIEWS:
            return
        else:
            view_str = view_func.__name__
            if view_str == 'wrap':
                return

        if settings.DEBUG == True:
            #todo: dependency!
            try:
                from debug_toolbar.views import debug_media as debug_media_view
                if view_func == debug_media_view:
                    return
            except ImportError:
                pass

        logging.debug('user %s, view %s' % (request.user.username, view_str))
        logging.debug('next url is %s' %
                      request.REQUEST.get('next', 'nothing'))

        if 'view_log' in request.session:
            view_log = request.session['view_log']
        else:
            view_log = ViewLog()

        view_log.set_current(view_str)
        request.session['view_log'] = view_log
示例#2
0
 def setUp(self):
     self.state = SearchState()
     self.log = ViewLog()