Merge lp:~fujita-tomonori-deactivatedaccount/swift/s3api-unicode-fix-1 into lp:~hudson-openstack/swift/trunk

Proposed by FUJITA Tomonori
Status: Merged
Approved by: Chuck Thier
Approved revision: 176
Merged at revision: 182
Proposed branch: lp:~fujita-tomonori-deactivatedaccount/swift/s3api-unicode-fix-1
Merge into: lp:~hudson-openstack/swift/trunk
Diff against target: 22 lines (+2/-3)
1 file modified
swift/common/middleware/swift3.py (+2/-3)
To merge this branch: bzr merge lp:~fujita-tomonori-deactivatedaccount/swift/s3api-unicode-fix-1
Reviewer Review Type Date Requested Status
Chuck Thier (community) Approve
Review via email: mp+46687@code.launchpad.net

Description of the change

Fixes swift3 middleware so that container listings work correctly with utf-8 encoded container names.

To post a comment you must log in.
Revision history for this message
Chuck Thier (cthier) wrote :

This still doesn't seem to work completely, but I think the issue is with boto. I imagine boto doesn't try to care about unicode, since I'm pretty sure that you can't have unicode container names. So while the requests work, some of the built in printing functions don't work properly.

To see the errors that I am seeing,

Run the functests, which will leave several containers that have utf-8 encoded container names. If you connect with boto, then run get_all_containers() and print the result, it errors. If you work with the results directly, it seems to work fine. I'm not entirely sure if there is anything that we can do about this. I'll need to think about it a bit more, and discuss with my co-workers.

Revision history for this message
FUJITA Tomonori (fujita-tomonori-deactivatedaccount) wrote :

2011/1/19 Chuck Thier <email address hidden>:
> This still doesn't seem to work completely, but I think the issue is with boto.  I imagine boto doesn't try to care about unicode, since I'm pretty sure that you can't have unicode container names.  So while the requests work, some of the built in printing functions don't work properly.

How do you print container names?

Seems that the following code works for me with unicode container names:

def list_buckets():
    conn = create_conn()
    buckets = conn.get_all_buckets()
    for b in buckets:
        print b.name

> To see the errors that I am seeing,
>
> Run the functests, which will leave several containers that have utf-8 encoded container names.  If you connect with boto, then run get_all_containers() and print the result, it errors.  If you work with the results directly, it seems to work fine.  I'm not entirely sure if there is anything that we can do about this.  I'll need to think about it a bit more, and discuss with my co-workers.
> --
> https://code.launchpad.net/~fujita-tomonori/swift/s3api-unicode-fix-1/+merge/46687
> You are the owner of lp:~fujita-tomonori/swift/s3api-unicode-fix-1.
>

Revision history for this message
Chuck Thier (cthier) wrote :

After some further experimenting, it looks like the underlying objects still work as expected. The __repr__ doesn't, so if you try "print conn.get_all_buckets()" it gets an error, but I can live with that.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'swift/common/middleware/swift3.py'
2--- swift/common/middleware/swift3.py 2011-01-17 06:42:20 +0000
3+++ swift/common/middleware/swift3.py 2011-01-18 21:54:53 +0000
4@@ -139,11 +139,9 @@
5 return get_err_response('InvalidURI')
6
7 containers = loads(''.join(list(body_iter)))
8- resp = Response(content_type='text/xml')
9- resp.status = 200
10 # we don't keep the creation time of a backet (s3cmd doesn't
11 # work without that) so we use something bogus.
12- resp.body = '<?xml version="1.0" encoding="UTF-8"?>' \
13+ body = '<?xml version="1.0" encoding="UTF-8"?>' \
14 '<ListAllMyBucketsResult ' \
15 'xmlns="http://doc.s3.amazonaws.com/2006-03-01">' \
16 '<Buckets>%s</Buckets>' \
17@@ -151,6 +149,7 @@
18 % ("".join(['<Bucket><Name>%s</Name><CreationDate>' \
19 '2009-02-03T16:45:09.000Z</CreationDate></Bucket>' %
20 xml_escape(i['name']) for i in containers]))
21+ resp = Response(status=200, content_type='text/xml', body=body)
22 return resp
23
24