Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Patches related to SQS transport #82

Closed
wants to merge 2 commits into from

2 participants

@dahlia

[af7bef2] Proper handling of SQS queue name format

Unlike str.translate() method unicode.translate() method cannot take table encoded by string.maketrans() function. So I replaced CHARS_REPLACE_TABLE with a dict table of Unicode ordinals.

Before patched this, it could occur error like following in some cases:

Traceback (most recent call last):
  File "/Users/dahlia/Projects/styleshare-env/lib/python2.7/site-packages/gevent-0.13.6-py2.7-macosx-10.7-intel.egg/gevent/greenlet.py", line 390, in run
    result = self._run(*self.args, **self.kwargs)
  File "/Users/dahlia/Projects/styleshare-env/lib/python2.7/site-packages/kombu-1.4.3-py2.7.egg/kombu/transport/virtual/__init__.py", line 359, in queue_declare
    self._new_queue(queue, **kwargs)
  File "/Users/dahlia/Projects/styleshare-env/lib/python2.7/site-packages/kombu-1.4.3-py2.7.egg/kombu/transport/SQS.py", line 165, in _new_queue
    self.entity_name(queue),
  File "/Users/dahlia/Projects/styleshare-env/lib/python2.7/site-packages/kombu-1.4.3-py2.7.egg/kombu/transport/SQS.py", line 157, in entity_name
    return safe_str(name).translate(table)
TypeError: character mapping must return integer, None or unicode

[d54737c] Made SQS able to be configured by URL

urlparse.urlparse() normalizes URL schemes into all lowercases, so SQS transport cannot be resolved by URL-style configuration e.g. SQS://.... Added a lowercase version of alias for SQS as well to resolve SQS transport by URL-style configuration e.g. sqs://....

dahlia added some commits
@dahlia dahlia Unlike str.translate method, unicode.translate method cannot take tab…
…le encoded by string.maketrans function.

So replace CHARS_REPLACE_TABLE with dict table of Unicode ordinals.
af7bef2
@dahlia dahlia urlparse normalizes url schemes into all lowercases, so SQS transport…
… cannot be resolved by url-style configuration. Added an lowercase version of alias for SQS as well to resolve SQS transport by url-style conf.
d54737c
@ask ask closed this pull request from a commit
@dahlia dahlia unicode.translate cannot take table encoded by string.maketrans funct…
…ion.

It uses a dict mapping instead,
so this patch replaces CHARS_REPLACE_TABLE with a dict of Unicode ordinals.

Closes #82
c5b4d47
@ask ask closed this in c5b4d47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 15, 2011
  1. @dahlia

    Unlike str.translate method, unicode.translate method cannot take tab…

    dahlia authored
    …le encoded by string.maketrans function.
    
    So replace CHARS_REPLACE_TABLE with dict table of Unicode ordinals.
  2. @dahlia

    urlparse normalizes url schemes into all lowercases, so SQS transport…

    dahlia authored
    … cannot be resolved by url-style configuration. Added an lowercase version of alias for SQS as well to resolve SQS transport by url-style conf.
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 5 deletions.
  1. +3 −5 kombu/transport/SQS.py
  2. +1 −0  kombu/transport/__init__.py
View
8 kombu/transport/SQS.py
@@ -30,11 +30,9 @@
# dots are replaced by dash, all other punctuation
# replaced by underscore.
-CHARS_REPLACE = string.punctuation.replace('-', '') \
- .replace('_', '') \
- .replace('.', '')
-CHARS_REPLACE_TABLE = string.maketrans(CHARS_REPLACE + '.',
- "_" * len(CHARS_REPLACE) + '-')
+CHARS_REPLACE_TABLE = dict((ord(c), 95)
+ for c in string.punctuation if c not in '-_.')
+CHARS_REPLACE_TABLE[46] = 45
class Table(Domain):
View
1  kombu/transport/__init__.py
@@ -76,6 +76,7 @@ def __inner():
"memory": "kombu.transport.memory.Transport",
"redis": "kombu.transport.pyredis.Transport",
"SQS": "kombu.transport.SQS.Transport",
+ "sqs": "kombu.transport.SQS.Transport",
"beanstalk": "kombu.transport.beanstalk.Transport",
"mongodb": "kombu.transport.mongodb.Transport",
"couchdb": "kombu.transport.pycouchdb.Transport",
Something went wrong with that request. Please try again.