Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added try/except that prints the exception to the console for the aja…

…x_upload view. this makes debugging a little easier.
  • Loading branch information...
commit 515792d7b6d6d84659351a798640e35b494ba5d7 1 parent ffb7f9b
@stefanfoulis authored
Showing with 46 additions and 44 deletions.
  1. +46 −44 image_filer/views.py
View
90 image_filer/views.py
@@ -213,50 +213,52 @@ def ajax_upload(request, folder_id=None):
#print request.POST
# flashcookie-hack (flash does not submit the cookie, so we send the
# django sessionid over regular post
-
- engine = __import__(settings.SESSION_ENGINE, {}, {}, [''])
- #session_key = request.POST.get('jsessionid')
- session_key = request.POST.get('jsessionid')
- request.session = engine.SessionStore(session_key)
- request.user = User.objects.get(id=request.session['_auth_user_id'])
- #print request.session['_auth_user_id']
- #print session_key
- #print engine
- #print request.user
- #print request.session
- # upload and save the file
- if not request.method == 'POST':
- return HttpResponse("must be POST")
- original_filename = request.POST.get('Filename')
- file = request.FILES.get('Filedata')
- #print request.FILES
- #print original_filename, file
- clipboard, was_clipboard_created = Clipboard.objects.get_or_create(user=request.user)
- files = generic_handle_file(file, original_filename)
- file_items = []
- for ifile, iname in files:
- try:
- iext = os.path.splitext(iname)[1].lower()
- except:
- iext = ''
- #print "extension: ", iext
- if iext in ['.jpg','.jpeg','.png','.gif']:
- imageform = UploadFileForm({'original_filename':iname,'owner': request.user.pk}, {'file':ifile})
- if imageform.is_valid():
- #print 'imageform is valid'
- try:
- image = imageform.save(commit=False)
- image.save()
- file_items.append(image)
- except Exception, e:
- print e
- #print "save %s" % image
- bi = ClipboardItem(clipboard=clipboard, file=image)
- bi.save()
- #sprint image
- else:
- pass#print imageform.errors
-
+ try:
+ engine = __import__(settings.SESSION_ENGINE, {}, {}, [''])
+ #session_key = request.POST.get('jsessionid')
+ session_key = request.POST.get('jsessionid')
+ request.session = engine.SessionStore(session_key)
+ request.user = User.objects.get(id=request.session['_auth_user_id'])
+ #print request.session['_auth_user_id']
+ #print session_key
+ #print engine
+ #print request.user
+ #print request.session
+ # upload and save the file
+ if not request.method == 'POST':
+ return HttpResponse("must be POST")
+ original_filename = request.POST.get('Filename')
+ file = request.FILES.get('Filedata')
+ #print request.FILES
+ #print original_filename, file
+ clipboard, was_clipboard_created = Clipboard.objects.get_or_create(user=request.user)
+ files = generic_handle_file(file, original_filename)
+ file_items = []
+ for ifile, iname in files:
+ try:
+ iext = os.path.splitext(iname)[1].lower()
+ except:
+ iext = ''
+ #print "extension: ", iext
+ if iext in ['.jpg','.jpeg','.png','.gif']:
+ imageform = UploadFileForm({'original_filename':iname,'owner': request.user.pk}, {'file':ifile})
+ if imageform.is_valid():
+ #print 'imageform is valid'
+ try:
+ image = imageform.save(commit=False)
+ image.save()
+ file_items.append(image)
+ except Exception, e:
+ print e
+ #print "save %s" % image
+ bi = ClipboardItem(clipboard=clipboard, file=image)
+ bi.save()
+ #sprint image
+ else:
+ pass#print imageform.errors
+ except Exception, e:
+ print e
+ raise e
return render_to_response('image_filer/include/clipboard_item_rows.html', {'items': file_items }, context_instance=RequestContext(request))
@login_required
Please sign in to comment.
Something went wrong with that request. Please try again.