Limitations on keys

Jay Doane jay at almery.com
Fri Sep 4 14:19:38 EDT 2009


Hi,

My application needs to use URLs as keys, but I'm forced to quote them  
for it to work, as demonstrated below.

 >>> import jiak
 >>> jc = jiak.JiakClient('localhost', 8098)
 >>> jc.set_bucket_schema('test', [])
 >>> jc.list_bucket('test')
{u'keys': [],
  u'schema': {u'allowed_fields': [],
              u'read_mask': [],
              u'required_fields': [],
              u'write_mask': []}}
 >>> jo = jiak.JiakObject('test', 'http://example.com')
 >>> jc.store(jo)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/Users/jay/Library/Python/2.6/site-packages/jiak.py", line  
94, in store
     {"Content-Type": "application/json"}))
   File "/Users/jay/Library/Python/2.6/site-packages/jiak.py", line  
69, in _expect
     raise JiakException(Resp.status, Resp.reason, Resp.read())
jiak.JiakException: (405, 'Method Not Allowed', '')
 >>> jo = jiak.JiakObject('test', urllib.quote_plus('http:// 
example.com'))
 >>> jc.store(jo)
 >>> jc.fetch('test', urllib.quote_plus('http://example.com')).key
'http%3A%2F%2Fexample.com'

The problem seems to occur because the key is simply appended to the  
JSON request, implying that any key containing characters with special  
meaning to a request may also fail to work.

My naive approach would be to quote the keys (and buckets as well?) in  
the client and unquote them at the server so the actual values would  
not change.  Is this a change the riak developers would accept, or is  
there a better approach?  Or are keys just limited by design (I hope  
not!).

Thanks,
Jay




More information about the riak-users mailing list