rename Document.get to Document.load to avoid masking dict.get

This commit is contained in:
Noah Levitt 2017-02-24 16:52:59 -08:00
parent 3c1faded3c
commit ad0e1b1fd7
3 changed files with 7 additions and 7 deletions

View File

@ -157,7 +157,7 @@ class Document(dict, object):
return cls.__name__.lower()
@classmethod
def get(cls, rethinker, pk):
def load(cls, rethinker, pk):
'''
Retrieve an instance from the database.
'''

View File

@ -3,7 +3,7 @@ import codecs
setuptools.setup(
name='rethinkstuff',
version='0.2.0.dev61',
version='0.2.0.dev62',
packages=['rethinkstuff'],
classifiers=[
'Programming Language :: Python :: 2.7',

View File

@ -369,7 +369,7 @@ def test_orm(r):
assert d._updates == {}
assert d._deletes == set()
d_copy = SomeDoc.get(r, d.id)
d_copy = SomeDoc.load(r, d.id)
assert d == d_copy
d['zuh'] = 'toot'
@ -385,7 +385,7 @@ def test_orm_pk(r):
rethinker.table_create(cls.table, primary_key='not_id').run()
with pytest.raises(Exception):
NonstandardPrimaryKey.get(r, 'no_such_thing')
NonstandardPrimaryKey.load(r, 'no_such_thing')
NonstandardPrimaryKey.table_create(r)
@ -398,7 +398,7 @@ def test_orm_pk(r):
assert len(f.keys()) == 1
with pytest.raises(KeyError):
NonstandardPrimaryKey.get(r, 'no_such_thing')
NonstandardPrimaryKey.load(r, 'no_such_thing')
# new doc with (only) primary key
d = NonstandardPrimaryKey(r, {'not_id': 1})
@ -406,7 +406,7 @@ def test_orm_pk(r):
assert d.pk_value == 1
d.save()
d_copy = NonstandardPrimaryKey.get(r, 1)
d_copy = NonstandardPrimaryKey.load(r, 1)
assert d == d_copy
# new doc with something in it
@ -418,7 +418,7 @@ def test_orm_pk(r):
e.save()
assert e.not_id
e_copy = NonstandardPrimaryKey.get(r, e.not_id)
e_copy = NonstandardPrimaryKey.load(r, e.not_id)
assert e == e_copy
e_copy['blah'] = 'toot'
e_copy.save()