| author | cavaliet |
| Fri, 29 Apr 2011 10:58:24 +0200 | |
| changeset 71 | 8a881c9593d0 |
| child 323 | f85caa66acf4 |
| permissions | -rw-r--r-- |
|
71
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
1 |
"""This middleware takes the session identifier in a POST message and adds it to the cookies instead. |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
2 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
3 |
This is necessary because SWFUpload won't send proper cookies back; instead, all the cookies are |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
4 |
added to the form that gets POST-ed back to us. |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
5 |
""" |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
6 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
7 |
from django.conf import settings |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
8 |
from django.core.urlresolvers import reverse |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
9 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
10 |
class SWFUploadMiddleware(object): |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
11 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
12 |
def process_request(self, request): |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
13 |
if (request.method == 'POST') and (request.path == reverse('ldt.ldt_utils.views.upload')) and (settings.SESSION_COOKIE_NAME in request.POST): |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
14 |
request.COOKIES[settings.SESSION_COOKIE_NAME] = request.POST[settings.SESSION_COOKIE_NAME] |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
15 |
|
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
16 |
if request.POST.has_key('csrfmiddlewaretoken'): |
|
8a881c9593d0
Add swfupload for local upload to create content view, with progress bar and error management.
cavaliet
parents:
diff
changeset
|
17 |
request.COOKIES['csrftoken'] = request.POST['csrfmiddlewaretoken'] |