[ckan-changes] commit/ckanext-storage: rgrp: [api/auth_form][s]: redirect on upload success to empty page with 200 in order to fix obscure bug with firefox.
Bitbucket
commits-noreply at bitbucket.org
Wed Sep 14 19:19:26 UTC 2011
1 new changeset in ckanext-storage:
http://bitbucket.org/okfn/ckanext-storage/changeset/9f146cae3e48/
changeset: 9f146cae3e48
user: rgrp
date: 2011-09-14 21:19:16
summary: [api/auth_form][s]: redirect on upload success to empty page with 200 in order to fix obscure bug with firefox.
* Details: we were redirecting to api metadata. This is json and in FF this leads to FF opening download/open dialogue (as file served as application/json or similar) this stops upload completing.
affected #: 2 files (586 bytes)
--- a/ckanext/storage/__init__.py Fri Sep 09 12:46:56 2011 +0100
+++ b/ckanext/storage/__init__.py Wed Sep 14 20:19:16 2011 +0100
@@ -37,6 +37,9 @@
route_map.connect('storage_upload_success', '/storage/upload/success',
controller='ckanext.storage.controller:StorageController',
action='success')
+ route_map.connect('storage_upload_success_empty', '/storage/upload/success_empty',
+ controller='ckanext.storage.controller:StorageController',
+ action='success_empty')
route_map.connect('storage_file', '/storage/f/{label:.*}',
controller='ckanext.storage.controller:StorageController',
action='file')
--- a/ckanext/storage/controller.py Fri Sep 09 12:46:56 2011 +0100
+++ b/ckanext/storage/controller.py Wed Sep 14 20:19:16 2011 +0100
@@ -188,6 +188,7 @@
:return: is a json hash containing various attributes including a
headers dictionary containing an Authorization field which is good for
15m.
+
'''
bucket = BUCKET
if request.POST:
@@ -231,7 +232,11 @@
}]
conditions = [ '{"%s": "%s"}' % (x['name'], x['value']) for x in
fields ]
- success_action_redirect = h.url_for('storage_api_get_metadata', qualified=True,
+ # In FF redirect to this breaks js upload as FF attempts to open file
+ # (presumably because mimetype = javascript) and this stops js
+ # success_action_redirect = h.url_for('storage_api_get_metadata', qualified=True,
+ # label=label)
+ success_action_redirect = h.url_for('storage_upload_success_empty', qualified=True,
label=label)
data = self.ofs.conn.build_post_form_args(
BUCKET,
@@ -396,6 +401,10 @@
c.upload_url = h.url_for('storage_upload')
return render('ckanext/storage/success.html')
+ def success_empty(self, label=None):
+ # very simple method that just returns 200 OK
+ return ''
+
def file(self, label):
exists = self.ofs.exists(BUCKET, label)
if not exists:
Repository URL: https://bitbucket.org/okfn/ckanext-storage/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list