diff --git a/README.md b/README.md
index 8c41f56b..83724024 100644
--- a/README.md
+++ b/README.md
@@ -3,32 +3,25 @@ py-arango
[](https://travis-ci.org/Joowani/py-arango)
-[](https://readthedocs.org/projects/py-arango/?badge=latest)
-Driver for ArangoDB REST API
+Python Driver for ArangoDB REST API
Overview
--------
-py-arango is a Python (2.7, 3.4) driver for ArangoDB
+py-arango is a Python 2.7 & 3.4 driver for ArangoDB
()
-Documentation
--------------
-
-
-
Installation
------------
-- Stable
+- Stable (ArangoDB Version 2.5)
```bash
sudo pip install py-arango
```
-- Latest
+- Latest (ArangoDB Version 2.5)
```bash
git clone https://github.com/Joowani/py-arango.git
diff --git a/arango/database.py b/arango/database.py
index ae005291..02256ed1 100644
--- a/arango/database.py
+++ b/arango/database.py
@@ -404,10 +404,9 @@ def remove_aql_function(self, name, group=None):
# Transactions #
################
- # TODO deal with optional attribute "params"
def execute_transaction(self, action, read_collections=None,
- write_collections=None, wait_for_sync=False,
- lock_timeout=None):
+ write_collections=None, params=None,
+ wait_for_sync=False, lock_timeout=None):
"""Execute the transaction and return the result.
Setting the ``lock_timeout`` to 0 will make ArangoDB not time out
@@ -419,6 +418,8 @@ def execute_transaction(self, action, read_collections=None,
:type read_collections: str or list or None
:param write_collections: the collections written to
:type write_collections: str or list or None
+ :param params: Parameters for the function in action
+ :type params: list or dict or None
:param wait_for_sync: wait for the transaction to sync to disk
:type wait_for_sync: bool
:param lock_timeout: timeout for waiting on collection locks
@@ -433,11 +434,13 @@ def execute_transaction(self, action, read_collections=None,
data["collections"]["read"] = read_collections
if write_collections is not None:
data["collections"]["write"] = write_collections
- params = {
+ if params is not None:
+ data["params"] = params
+ http_params = {
"waitForSync": wait_for_sync,
"lockTimeout": lock_timeout,
}
- res = self._api.post(path=path, data=data, params=params)
+ res = self._api.post(path=path, data=data, params=http_params)
if res.status_code != 200:
raise TransactionExecuteError(res)
return res.obj["result"]
diff --git a/arango/tests/test_transaction.py b/arango/tests/test_transaction.py
index 70c0c407..c132a24e 100644
--- a/arango/tests/test_transaction.py
+++ b/arango/tests/test_transaction.py
@@ -44,5 +44,33 @@ def test_execute_transaction(self):
self.assertIn("doc02", self.col02)
+ def test_execute_transaction_params(self):
+ action = """
+ function (params) {
+ var db = require('internal').db;
+ db.%s.save({ _key: 'doc11', val: params.val1 });
+ db.%s.save({ _key: 'doc12', val: params.val2 });
+ return 'success!';
+ }
+ """ % (self.col_name01, self.col_name02)
+
+ params = {"val1": 1, "val2": 2}
+
+ res = self.db.execute_transaction(
+ action=action,
+ read_collections=[self.col_name01, self.col_name02],
+ write_collections=[self.col_name01, self.col_name02],
+ params=params,
+ wait_for_sync=True,
+ lock_timeout=10000
+ )
+
+ self.assertEqual(res, "success!")
+ self.assertIn("doc11", self.col01)
+ self.assertIn("doc12", self.col02)
+ self.assertEqual(self.col01["doc11"]["val"], params["val1"])
+ self.assertEqual(self.col02["doc12"]["val"], params["val2"])
+
+
if __name__ == "__main__":
unittest.main()