links within a base

24 views
Skip to first unread message

John

unread,
Jun 6, 2010, 2:34:43 AM6/6/10
to buzhug
it seems one can't link within a base, i.e.
persons = Base('persons')
persons.create(('name',str),('parent',persons))
?
i'm able to fill the base with data, but i get an error when i try to
reopen it from disk, i.e.

persons = Base('persons').open()

I get
"
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (30,0)
"
basically each record contains a 'parent' field with a pointer to it's
parent, and though you are able to fill the base, there seem to be
read/write (pickling?) disk issues.

just something for the wishlist :)

thanks
John

Pierre Quentel

unread,
Jun 7, 2010, 3:39:53 PM6/7/10
to buzhug
Hi John,

Welcome to the group, and thanks for the report !

I didn't think of this case, but it certainly makes sense. I tried
this simple script :

=============
import random
from buzhug import Base

persons = Base('persons')
persons.create(('name',str),('parent',persons),mode="override")

for i in range(10):
persons.insert(name='pierre') # parent is set to None

for i in range(100):
persons.insert(name='simon',parent=persons[random.randint(0,10)])

persons.close()

p2 = Base('persons').open()
===============

It raised an exception, but not the one you mention, it was a "maximum
recursion depth"

I tried this patch, which worked for the test above : in line 442 of
buzhug.py, replace the block by :

if v.startswith('<base>'):
# reference to an external base
base_path = urllib.unquote(v[6:])
if base_path == self.name:
ext_db = self
else:
ext_db = Base(base_path).open()
self._register_base(ext_db)
self.fields[k] = ext_db
else:
self.fields[k] = self.types[v]

Does this solve the problem in your script ? If so I will include the
patch in a future version

Best regards,
Pierre

Arthur

unread,
Jun 7, 2010, 8:58:00 PM6/7/10
to buz...@googlegroups.com

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes buzhug.
Pour envoyer un message à ce groupe, adressez un e-mail à buz...@googlegroups.com.
Pour vous désabonner de ce groupe, envoyez un e-mail à l'adresse buzhug+un...@googlegroups.com.
Pour plus d'options, consultez la page de ce groupe : http://groups.google.com/group/buzhug?hl=fr


Pierre

   Your patch fixed the problem.

   thank you!!
 
John
Reply all
Reply to author
Forward
0 new messages