Commit a64d810d authored by Jens Langhammer's avatar Jens Langhammer

Improve S3 Compatibility by removing ns0: prefix in XML Responses

parent 4f607051
Pipeline #3844 passed with stage
in 4 minutes and 36 seconds
......@@ -99,7 +99,7 @@ class Blob(UUIDModel, TagModel):
def filename(self):
"""Return only the filename part of self.path"""
return self.path.split('/')[-1]
return self.path
def _open_read_handle(self):
if not self._reading_handle:
"""p2 S3 App Config"""
from xml.etree import ElementTree
from django.apps import AppConfig
from p2.s3.constants import XML_NAMESPACE
class P2S3Config(AppConfig):
"""p2 S3 App Config"""
......@@ -8,3 +12,6 @@ class P2S3Config(AppConfig):
name = 'p2.s3'
label = 'p2_s3'
verbose_name = 'p2 S3'
def ready(self):
ElementTree.register_namespace("", XML_NAMESPACE)
......@@ -4,6 +4,7 @@ from xml.etree import ElementTree
from django.views import View
from guardian.shortcuts import get_objects_for_user
from p2.s3.constants import XML_NAMESPACE
from p2.s3.http import XMLResponse
......@@ -12,22 +13,18 @@ class ListView(View):
def get(self, request):
"""Return list of Buckets"""
root = ElementTree.Element("{}ListAllMyBucketsResult")
root = ElementTree.Element("{%s}ListAllMyBucketsResult" % XML_NAMESPACE)
owner = ElementTree.Element("Owner")
owner_id = ElementTree.SubElement(owner, 'ID')
owner_id.text = str(
owner_display_name = ElementTree.SubElement(owner, 'DisplayName')
owner_display_name.text = request.user.username
ElementTree.SubElement(owner, 'ID').text = str(
ElementTree.SubElement(owner, 'DisplayName').text = request.user.username
buckets = ElementTree.Element('Buckets')
for volume in get_objects_for_user(self.request.user, 'p2_core.use_volume'):
bucket = ElementTree.Element("Bucket")
bucket_name = ElementTree.SubElement(bucket, "Name")
bucket_name.text =
bucket_creation_date = ElementTree.SubElement(bucket, "CreationDate")
bucket_creation_date.text = "2006-02-03T16:45:09.000Z"
ElementTree.SubElement(bucket, "Name").text =
ElementTree.SubElement(bucket, "CreationDate").text = "2006-02-03T16:45:09.000Z"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment