Skip to content

Commit 20118b9

Browse files
committed
Revamp the library for 5.0.0.
1 parent 8199148 commit 20118b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2121
-2125
lines changed

.travis.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
sudo: false
22
language: python
3-
python:
4-
- 2.7
5-
- 3.4
6-
- 3.5
7-
- 3.6
3+
matrix:
4+
include:
5+
- python: 2.7
6+
- python: 3.4
7+
- python: 3.5
8+
- python: 3.6
9+
- python: 3.7
10+
dist: xenial
11+
sudo: true
812
services:
913
- docker
1014
before_install:
11-
- docker run --name arango -d -p 8529:8529 -e ARANGO_ROOT_PASSWORD=passwd arangodb/arangodb:3.4.0
15+
- docker run --name arango -d -p 8529:8529 -e ARANGO_ROOT_PASSWORD=passwd arangodb/arangodb:3.5.0
1216
- docker cp tests/static/service.zip arango:/tmp/service.zip
1317
install:
14-
- pip install flake8 mock pytest pytest-cov python-coveralls sphinx sphinx_rtd_theme
18+
- pip install flake8 mock
19+
- pip install pytest==3.5.1
20+
- pip install pytest-cov==2.5.1
21+
- pip install python-coveralls==2.9.1
22+
- pip install sphinx sphinx_rtd_theme
1523
- pip install .
1624
script:
1725
- python -m flake8

README.rst

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
:target: https://coveralls.io/github/joowani/python-arango?branch=master
2323
:alt: Test Coverage
2424

25-
.. image:: https://img.shields.io/github/issues/joowani/python-arango.svg
25+
.. image:: https://img.shields.io/github/issues/joowani/python-arango.svg
2626
:target: https://github.com/joowani/python-arango/issues
2727
:alt: Issues Open
2828

29-
.. image:: https://img.shields.io/badge/license-MIT-blue.svg
29+
.. image:: https://img.shields.io/badge/license-MIT-blue.svg
3030
:target: https://raw.githubusercontent.com/joowani/python-arango/master/LICENSE
3131
:alt: MIT License
3232

@@ -37,23 +37,25 @@ Welcome to the GitHub page for **python-arango**, a Python driver for ArangoDB_.
3737
Announcements
3838
=============
3939

40-
- Python-arango version `4.0.0`_ is now out!
41-
- Please see the releases_ page for latest updates.
40+
- Python-arango version `5.0.0`_ is finally up! This release supports ArangoDB
41+
version 3.5+ only. It also breaks backward-compatibility and you must make
42+
changes in your application code. Please see the releases_ page for details.
4243

4344
Features
4445
========
4546

46-
- Clean Pythonic interface.
47-
- Lightweight.
48-
- High ArangoDB REST API coverage.
47+
- Pythonic interface
48+
- Lightweight
49+
- High API coverage
4950

5051
Compatibility
5152
=============
5253

53-
- Python versions 2.7, 3.4, 3.5 and 3.6 are supported.
54-
- Python-arango 4.x supports ArangoDB 3.3+ (recommended).
55-
- Python-arango 3.x supports ArangoDB 3.0 ~ 3.2 only.
56-
- Python-arango 2.x supports ArangoDB 1.x ~ 2.x only.
54+
- Python versions 2.7, 3.4, 3.5, 3.6 and 3.7 are supported
55+
- Python-arango 5.x supports ArangoDB 3.5+
56+
- Python-arango 4.x supports ArangoDB 3.3 ~ 3.4 only
57+
- Python-arango 3.x supports ArangoDB 3.0 ~ 3.2 only
58+
- Python-arango 2.x supports ArangoDB 1.x ~ 2.x only
5759

5860
Installation
5961
============
@@ -83,7 +85,7 @@ Here is a simple usage example:
8385
from arango import ArangoClient
8486
8587
# Initialize the client for ArangoDB.
86-
client = ArangoClient(protocol='http', host='localhost', port=8529)
88+
client = ArangoClient(hosts='http://localhost:8529')
8789
8890
# Connect to "_system" database as root user.
8991
sys_db = client.db('_system', username='root', password='passwd')
@@ -117,7 +119,7 @@ Here is another example with graphs:
117119
from arango import ArangoClient
118120
119121
# Initialize the client for ArangoDB.
120-
client = ArangoClient(protocol='http', host='localhost', port=8529)
122+
client = ArangoClient(hosts='http://localhost:8529')
121123
122124
# Connect to "test" database as root user.
123125
db = client.db('test', username='root', password='passwd')
@@ -169,7 +171,7 @@ Contributing
169171
Please take a look at this page_ before submitting a pull request. Thanks!
170172

171173
.. _ArangoDB: https://www.arangodb.com
172-
.. _4.0.0: https://github.com/joowani/python-arango/releases/tag/4.0.0
174+
.. _5.0.0: https://github.com/joowani/python-arango/releases/tag/5.0.0
173175
.. _releases: https://github.com/joowani/python-arango/releases
174176
.. _PyPi: https://pypi.python.org/pypi/python-arango
175177
.. _GitHub: https://github.com/joowani/python-arango

arango/api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class APIWrapper(object):
1515
def __init__(self, connection, executor):
1616
self._conn = connection
1717
self._executor = executor
18-
self._is_transaction = self.context == 'transaction'
1918

2019
@property
2120
def db_name(self):

arango/aql.py

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import absolute_import, unicode_literals
22

3-
from json import dumps
4-
53
__all__ = ['AQL', 'AQLQueryCache']
64

75
from arango.api import APIWrapper
@@ -42,7 +40,7 @@ def __repr__(self):
4240
return '<AQL in {}>'.format(self._conn.db_name)
4341

4442
# noinspection PyMethodMayBeStatic
45-
def _format_tracking(self, body):
43+
def _format_tracking_properties(self, body):
4644
"""Format the tracking properties.
4745
4846
:param body: Response body.
@@ -237,10 +235,10 @@ def execute(self,
237235
enterprise version of ArangoDB.
238236
:type satellite_sync_wait: int | float
239237
:param read_collections: Names of collections read during query
240-
execution. Required for :doc:`transactions <transaction>`.
238+
execution. This parameter is deprecated.
241239
:type read_collections: [str | unicode]
242240
:param write_collections: Names of collections written to during query
243-
execution. Required for :doc:`transactions <transaction>`.
241+
execution. This parameter is deprecated.
244242
:type write_collections: [str | unicode]
245243
:param stream: If set to True, query is executed in streaming fashion:
246244
query result is not stored server-side but calculated on the fly.
@@ -310,17 +308,10 @@ def execute(self,
310308
data['options'] = options
311309
data.update(options)
312310

313-
command = 'db._query({}, {}, {}).toArray()'.format(
314-
dumps(query),
315-
dumps(bind_vars),
316-
dumps(data),
317-
) if self._is_transaction else None
318-
319311
request = Request(
320312
method='post',
321313
endpoint='/_api/cursor',
322314
data=data,
323-
command=command,
324315
read=read_collections,
325316
write=write_collections
326317
)
@@ -425,7 +416,7 @@ def tracking(self):
425416
def response_handler(resp):
426417
if not resp.is_success:
427418
raise AQLQueryTrackingGetError(resp, request)
428-
return self._format_tracking(resp.body)
419+
return self._format_tracking_properties(resp.body)
429420

430421
return self._execute(request, response_handler)
431422

@@ -465,7 +456,7 @@ def set_tracking(self,
465456
def response_handler(resp):
466457
if not resp.is_success:
467458
raise AQLQueryTrackingSetError(resp, request)
468-
return self._format_tracking(resp.body)
459+
return self._format_tracking_properties(resp.body)
469460

470461
return self._execute(request, response_handler)
471462

@@ -563,6 +554,28 @@ class AQLQueryCache(APIWrapper):
563554
def __repr__(self):
564555
return '<AQLQueryCache in {}>'.format(self._conn.db_name)
565556

557+
# noinspection PyMethodMayBeStatic
558+
def _format_cache_properties(self, body):
559+
"""Format the query cache properties.
560+
561+
:param body: Response body.
562+
:type body: dict
563+
:return: Formatted body.
564+
:rtype: dict
565+
"""
566+
body.pop('code', None)
567+
body.pop('error', None)
568+
569+
if 'maxResults' in body:
570+
body['max_results'] = body.pop('maxResults')
571+
if 'maxResultsSize' in body:
572+
body['max_results_size'] = body.pop('maxResultsSize')
573+
if 'maxEntrySize' in body:
574+
body['max_entry_size'] = body.pop('maxEntrySize')
575+
if 'includeSystem' in body:
576+
body['include_system'] = body.pop('includeSystem')
577+
return body
578+
566579
def properties(self):
567580
"""Return the query cache properties.
568581
@@ -578,30 +591,47 @@ def properties(self):
578591
def response_handler(resp):
579592
if not resp.is_success:
580593
raise AQLCachePropertiesError(resp, request)
581-
return {
582-
'mode': resp.body['mode'],
583-
'limit': resp.body['maxResults']
584-
}
594+
return self._format_cache_properties(resp.body)
585595

586596
return self._execute(request, response_handler)
587597

588-
def configure(self, mode=None, limit=None):
598+
def configure(self,
599+
mode=None,
600+
max_results=None,
601+
max_results_size=None,
602+
max_entry_size=None,
603+
include_system=None):
589604
"""Configure the query cache properties.
590605
591606
:param mode: Operation mode. Allowed values are "off", "on" and
592607
"demand".
593608
:type mode: str | unicode
594-
:param limit: Max number of query results to be stored.
595-
:type limit: int
609+
:param max_results: Max number of query results stored per
610+
database-specific cache.
611+
:type max_results: int
612+
:param max_results_size: Max cumulative size of query results stored
613+
per database-specific cache.
614+
:type max_results_size: int
615+
:param max_entry_size: Max entry size of each query result stored per
616+
database-specific cache.
617+
:type max_entry_size: int
618+
:param include_system: Store results of queries in system collections.
619+
:type include_system: bool
596620
:return: Query cache properties.
597621
:rtype: dict
598622
:raise arango.exceptions.AQLCacheConfigureError: If operation fails.
599623
"""
600624
data = {}
601625
if mode is not None:
602626
data['mode'] = mode
603-
if limit is not None:
604-
data['maxResults'] = limit
627+
if max_results is not None:
628+
data['maxResults'] = max_results
629+
if max_results_size is not None:
630+
data['maxResultsSize'] = max_results_size
631+
if max_entry_size is not None:
632+
data['maxEntrySize'] = max_entry_size
633+
if include_system is not None:
634+
data['includeSystem'] = include_system
605635

606636
request = Request(
607637
method='put',
@@ -612,10 +642,7 @@ def configure(self, mode=None, limit=None):
612642
def response_handler(resp):
613643
if not resp.is_success:
614644
raise AQLCacheConfigureError(resp, request)
615-
return {
616-
'mode': resp.body['mode'],
617-
'limit': resp.body['maxResults']
618-
}
645+
return self._format_cache_properties(resp.body)
619646

620647
return self._execute(request, response_handler)
621648

@@ -642,7 +669,7 @@ def clear(self):
642669
"""Clear the query cache.
643670
644671
:return: True if query cache was cleared successfully.
645-
:rtype: dict
672+
:rtype: bool
646673
:raise arango.exceptions.AQLCacheClearError: If operation fails.
647674
"""
648675
request = Request(

0 commit comments

Comments
 (0)