fiorix/txredisapi — pull request #21 by ctavan (2012-07-06 20:18:51+00:00)
Title: Nested multi bulk replies

Hi there,

redis-cli outputs results from a transaction in a hierarchical view:

```
redis 127.0.0.1:6379> multi
OK
redis 127.0.0.1:6379> hmset key1 f1 11 f2 12
QUEUED
redis 127.0.0.1:6379> hmset key2 f1 21 f2 22
QUEUED
redis 127.0.0.1:6379> hgetall key1
QUEUED
redis 127.0.0.1:6379> hgetall key2
QUEUED
redis 127.0.0.1:6379> exec
1) OK
2) OK
3) 1) "f1"
2) "11"
3) "f2"
4) "12"
4) 1) "f1"
2) "21"
3) "f2"
4) "22"
redis 127.0.0.1:6379>
```

My patch adds support for similar functionality to the driver. Until now txredisapi would have returned just the first resultset when several multi bulk commands are issued within a transaction. With my patch the return values from all commands appear in the output and the output is now hierarchical for multi bulk commands that appear in a transaction:

```python
t = yield self.db.multi()
yield t.hmset(self._KEYS[0], {'foo': 'fooz', 'bar': 'baz'})
yield t.hmset(self._KEYS[1], {'foo2': 'fooz2', 'bar2': 'baz2'})
yield t.hgetall(self._keys[0])
yield t.hgetall(self._keys[1])
result = yield t.commit()
```

will result in

```python
result = [
'OK',
'OK',
[u'foo', u'fooz', u'bar', u'baz'],
[u'foo2', u'fooz2', u'bar2', u'baz2']
]
```

I guess the problem could be solved a bit more elegantly, if you have any suggestions I'm happy to include them!