Created
February 17, 2011 20:49
-
-
Save kingbuzzman/832652 to your computer and use it in GitHub Desktop.
session refer.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MainsiteMiddleware(object): | |
| def process_request(self, request): | |
| from mainsite.urls import urlpatterns | |
| current_path = request.META.get('PATH_INFO', '') | |
| inside_mainsite = False | |
| # loop over all the page of mainsite | |
| for url in urlpatterns: | |
| # check to see if there is a url match | |
| if url.resolve(current_path[1:]) or url.resolve(current_path): | |
| inside_mainsite = True | |
| break | |
| # if they are not in mainsite -- ignore | |
| if not inside_mainsite: | |
| return | |
| # check to see if they have the referer set -- if not, set it | |
| if 'HTTP_REFERER' not in request.session: | |
| request.session['HTTP_REFERER'] = current_path | |
| return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment