Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'output': 0.05; 'subject:Python': 0.06; 'skip:" 60': 0.07; 'skip:f 70': 0.09; 'def': 0.12; 'cjson': 0.16; 'subject:issue': 0.16; 'backend': 0.19; 'import': 0.22; 'exists': 0.24; 'question': 0.24; 'pass': 0.26; 'code:': 0.26; 'testing': 0.29; 'skip:p 30': 0.29; 'raise': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'requests': 0.31; "skip:' 10": 0.31; 'skip:& 70': 0.31; 'file': 0.32; 'class': 0.32; 'says': 0.33; '(most': 0.33; 'skip:# 10': 0.33; 'skip:b 30': 0.33; 'could': 0.34; 'received:google.com': 0.35; 'url:org': 0.36; 'skip:- 20': 0.37; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; 'url:3': 0.61; 'here': 0.66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=4jNi6rcAbqRlPnskTU1bqYuqNbri7Cug1XNylu4bTxw=; b=dc1qU0cROFyW1i6A9SX0fsFUkWglPm7kOA0WWd+gBDg0AI8H/6gadSY9RfPVhyDwGu 8rNi4kMa/N7hpQfyDxxkXG9TnXJ1bVFRK3Zoegn8K3vM4nOWTNGLXYzjJT1Fd/4eSiAz Fgxcb2E01hE/tJYn2tSh20jI0OuFS4SvSlkABqKatX7h6pTcotPenmjmo40URKb0unhV qbynZs5wiMzfuCr+hw/U/qd8tg0LrVwNKEqZZIa6P4DQlrzYTmSzfHcX6rt+CI1ikmXC RN/Kiw95TfSrHXXnutsa6K/S87lxYLoidcSu/GeiotljReF+Gl37xrhCc5uj3vmOktuu N9LA== X-Received: by 10.152.216.167 with SMTP id or7mr3996877lac.93.1413995680633; Wed, 22 Oct 2014 09:34:40 -0700 (PDT) MIME-Version: 1.0 From: Juan Christian Date: Wed, 22 Oct 2014 14:34:20 -0200 Subject: Python 3.4.1 and blitzdb issue To: Python Content-Type: multipart/alternative; boundary=001a1135e3184216970506058662 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 90 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413996099 news.xs4all.nl 2928 [2001:888:2000:d::a6]:60072 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79459 --001a1135e3184216970506058662 Content-Type: text/plain; charset=UTF-8 Testing code: CODE --------------------- #!/usr/bin/env import requests from blitzdb import Document, FileBackend API_URL = 'http://api.themoviedb.org/3' API_KEY = 'ddf3xxxxxxxx0289' class Actor(Document): pass def get_actor(_id): r = requests.get('{}/person/{}?api_key={}'.format(API_URL, str(_id), API_KEY)) return r.json() actor_1 = Actor(get_actor(1)) actor_2 = Actor(get_actor(2)) backend = FileBackend("db.blitz") actor_1.save(backend) actor_2.save(backend) print(backend.get(Actor,{'imdb_id' : 'nm0000184'})) print('\n') print(backend.get(Actor,{'imdb_id' : 'nm0000434'})) OUTPUT --------------------- Warning: cjson could not be imported, CJsonSerializer will not be available. Traceback (most recent call last): File ".\uff.py", line 27, in print(backend.get(Actor,{'imdb_id' : 'nm0000184'})) File "C:\Python34\lib\site-packages\blitzdb\backends\file\backend.py", line 456, in get raise cls.DoesNotExist blitzdb.document.DoesNotExist: DoesNotExist(Actor) QUESTION --------------------- Why the output says that Actor doesn't exists when I already added it here 'actor_1.save(backend)' and 'actor_2.save(backend)' --001a1135e3184216970506058662 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Testing code:

CODE=C2=A0---------= ------------

#!/usr/bin/env

import requests
from blitzdb import Document, FileBackend
=


API_KEY =3D= 'ddf3xxxxxxxx0289'


class A= ctor(Document):
=C2=A0 =C2=A0 pass


<= /div>
def get_actor(_id):
=C2=A0 =C2=A0 r =3D requests.get(&#= 39;{}/person/{}?api_key=3D{}'.format(API_URL, str(_id), API_KEY))
=
=C2=A0 =C2=A0 return r.json()


= actor_1 =3D Actor(get_actor(1))
actor_2 =3D Actor(get_actor(2))

backend =3D FileBackend("db.blitz")
=
actor_1.save(backend)
actor_2.save(backend)

print(backend.get(Actor,{'imdb_id' : 'nm0000184'})= )
print('\n')
print(backend.get(Actor,{'imd= b_id' : 'nm0000434'}))


OUTPUT ---------------------

Warning: c= json could not be imported, CJsonSerializer will not be available.
Traceback (most recent call last):
=C2=A0 File ".\uff.py&q= uot;, line 27, in <module>
=C2=A0 =C2=A0 print(backend.get(= Actor,{'imdb_id' : 'nm0000184'}))
=C2=A0 File &qu= ot;C:\Python34\lib\site-packages\blitzdb\backends\file\backend.py", li= ne 456, in get
=C2=A0 =C2=A0 raise cls.DoesNotExist
bli= tzdb.document.DoesNotExist: DoesNotExist(Actor)

<= div>
QUESTION ---------------------

= Why the output says that Actor doesn't exists when I already added it h= ere 'actor_1.save(backend)' and 'actor_2.save(backend)'
--001a1135e3184216970506058662--