[ckan-changes] commit/ckanext-storage: 3 new changesets
Bitbucket
commits-noreply at bitbucket.org
Fri Sep 9 11:47:07 UTC 2011
3 new changesets in ckanext-storage:
http://bitbucket.org/okfn/ckanext-storage/changeset/df549fe5825c/
changeset: df549fe5825c
user: rgrp
date: 2011-09-01 15:33:30
summary: [api/auth/form][xs]: fqdn in for local storage auth form action url.
affected #: 2 files (105 bytes)
--- a/ckanext/storage/controller.py Wed Aug 31 20:04:28 2011 +0100
+++ b/ckanext/storage/controller.py Thu Sep 01 14:33:30 2011 +0100
@@ -252,7 +252,7 @@
return self._get_remote_form_data(label)
else:
data = {
- 'action': h.url_for('storage_upload_handle'),
+ 'action': h.url_for('storage_upload_handle', qualified=True),
'fields': [
{
'name': 'key',
--- a/tests/test_storage.py Wed Aug 31 20:04:28 2011 +0100
+++ b/tests/test_storage.py Thu Sep 01 14:33:30 2011 +0100
@@ -93,6 +93,7 @@
def test_auth_form(self):
url = url_for('storage_api_auth_form', label='abc')
res = self.app.get(url, extra_environ=self.extra_environ, status=200)
+ assert res.json['action'] == u'http://localhost/storage/upload_handle', res.json
assert res.json['fields'][-1]['value'] == 'abc', res
url = url_for('storage_api_auth_form', label='abc/xxx')
http://bitbucket.org/okfn/ckanext-storage/changeset/6ed030c6c4f4/
changeset: 6ed030c6c4f4
user: rgrp
date: 2011-09-02 20:06:25
summary: [bugfix,storage/api][s]: fix get metadata with local storage (not working due to minor issue).
* Start on test for metadata API (but did not complete as not sure how to create metadata).
affected #: 3 files (756 bytes)
--- a/ckanext/storage/__init__.py Thu Sep 01 14:33:30 2011 +0100
+++ b/ckanext/storage/__init__.py Fri Sep 02 19:06:25 2011 +0100
@@ -13,7 +13,7 @@
def after_map(self, route_map):
c = "ckanext.storage.controller:StorageAPIController"
route_map.connect('storage_api', "/api/storage", controller=c, action="index")
- route_map.connect("/api/storage/metadata/{label:.*}", controller=c, action="set_metadata",
+ route_map.connect('storage_api_set_metadata', "/api/storage/metadata/{label:.*}", controller=c, action="set_metadata",
conditions={"method": ["PUT", "POST"]})
route_map.connect('storage_api_get_metadata', "/api/storage/metadata/{label:.*}", controller=c, action="get_metadata",
conditions={"method": ["GET"]})
--- a/ckanext/storage/controller.py Thu Sep 01 14:33:30 2011 +0100
+++ b/ckanext/storage/controller.py Fri Sep 02 19:06:25 2011 +0100
@@ -151,11 +151,19 @@
@jsonpify
def get_metadata(self, label):
bucket = BUCKET
- if not label.startswith("/"): label = "/" + label
+ storage_backend = config['ofs.impl']
+ if storage_backend in ['google', 's3']:
+ if not label.startswith("/"):
+ label = "/" + label
+ url = "https://%s/%s%s" % (self.ofs.conn.server_name(), bucket, label)
+ else:
+ url = h.url_for('storage_file',
+ label=label,
+ qualified=True
+ )
if not self.ofs.exists(bucket, label):
abort(404)
metadata = self.ofs.get_metadata(bucket, label)
- url = "https://%s/%s%s" % (self.ofs.conn.server_name(), bucket, label)
metadata["_location"] = url
return metadata
--- a/tests/test_storage.py Thu Sep 01 14:33:30 2011 +0100
+++ b/tests/test_storage.py Fri Sep 02 19:06:25 2011 +0100
@@ -100,3 +100,18 @@
res = self.app.get(url, extra_environ=self.extra_environ, status=200)
assert res.json['fields'][-1]['value'] == 'abc/xxx'
+ def test_metadata(self):
+ url = url_for('storage_api_get_metadata', label='abc')
+ res = self.app.get(url, status=404)
+
+ # TODO: test get metadata on real setup ...
+ label = 'abc'
+ url = url_for('storage_api_set_metadata',
+ extra_environ=self.extra_environ,
+ label=label,
+ data=dict(
+ label=label
+ )
+ )
+ # res = self.app.get(url, status=404)
+
http://bitbucket.org/okfn/ckanext-storage/changeset/44121e696e98/
changeset: 44121e696e98
user: rgrp
date: 2011-09-09 13:46:56
summary: [upload/localfile,bugfix][s]: do not redirect from upload action to success as this breaks js upload.
* Also do not both setting Content-Disposition attachement on download for local files (no need ...)
affected #: 1 file (181 bytes)
--- a/ckanext/storage/controller.py Fri Sep 02 19:06:25 2011 +0100
+++ b/ckanext/storage/controller.py Fri Sep 09 12:46:56 2011 +0100
@@ -381,12 +381,16 @@
self.ofs.put_stream(bucket_id, label, stream.file, params)
success_action_redirect = h.url_for('storage_upload_success', qualified=True,
bucket=BUCKET, label=label)
- h.redirect_to(success_action_redirect)
+ # Cannot redirect here as it breaks js file uploads (get infinite loop
+ # in FF and crash in Chrome)
+ # h.redirect_to(success_action_redirect)
+ return self.success(label)
- def success(self):
+ def success(self, label=None):
+ label=request.params.get('label', label)
h.flash_success('Upload successful')
c.file_url = h.url_for('storage_file',
- label=request.params.get('label', ''),
+ label=label,
qualified=True
)
c.upload_url = h.url_for('storage_upload')
@@ -409,9 +413,9 @@
if file_url.startswith("file://"):
metadata = self.ofs.get_metadata(BUCKET, label)
filepath = file_url[len("file://"):]
- headers = {'Content-Disposition':'attachment; filename="%s"' %
- label,
- 'Content-Type':metadata.get('_format', 'text/plain')}
+ headers = {
+ # 'Content-Disposition':'attachment; filename="%s"' % label,
+ 'Content-Type':metadata.get('_format', 'text/plain')}
fapp = FileApp(filepath, headers=None, **headers)
return fapp(request.environ, self.start_response)
else:
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