Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

mostly worrying about docstrings

  • Loading branch information...
commit fe5009c4d2cb29501f70ebdc3eb9a4fa18f1d444 1 parent ad168bc
@atl authored
Showing with 13 additions and 3 deletions.
  1. +1 −1  docs/proxy.rst
  2. +12 −2 redish/proxy.py
View
2  docs/proxy.rst
@@ -212,7 +212,7 @@ of the keyspaces, so the following is equivalent to the above::
>>> x['myspace', 1]
u'Bob'
-One can debug the keyspaces by feeding a tuple to `actual_key`::
+One can debug the keyspaces by feeding a tuple to ``actual_key``::
>>> x.actual_key((UNAME, 202))
'person:0202:name'
View
14 redish/proxy.py
@@ -52,6 +52,9 @@ class Proxy(Redis):
def __init__(self, *args, **kwargs):
"""
+ This mostly defers to the main redis-py object, with the exception of
+ keeping track of empty elements and keyspaces.
+
If a user attempts to initialize a redis key with an empty container,
that container is kept in the (local thread's) proxy object so that
subsequent accesses keep the right type without throwing KeyErrors.
@@ -70,6 +73,8 @@ def preprocessed(self, key, *argv):
keyargs = tuple(key[1:])
key = self._keyspaces[keyspace] % keyargs
return f(self, key, *argv)
+ preprocessed.__doc__ = f.__doc__
+ preprocessed.__name__ = f.__name__
return preprocessed
@keyspaced
@@ -158,8 +163,12 @@ def register_keyspace(self, shortcut, formatstring):
symbolic access with this pattern::
VALUE = proxyobject.register_keyspace('val', "user:%d:name")
+
+ The following three statements are then all equivalent::
+
proxyobject[VALUE, 1001] = "Fred"
- proxyobject['val', 1001]
+ proxyobject['val', 1001] = "Fred"
+ proxyobject['user:1001:name'] = "Fred"
"""
self._keyspaces[shortcut] = formatstring
return shortcut
@@ -180,7 +189,8 @@ def actual_key(self, key):
class KeyspacedProxy(Proxy):
"""
- The best way of describing this is that it simulates a partial using the keyspace.
+ The easiest way of describing this is that it simulates a partial on the
+ mapping object by interpolating the keyspace. Clear?
"""
def __init__(self, proxy, transform):
self.proxy = proxy
Please sign in to comment.
Something went wrong with that request. Please try again.