[Zope] Newbie questions about OOBTree, persistence

Glen Ecklund Glen@TheGeoGroup.com
Fri, 25 Apr 2003 09:58:59 -0500


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body>
<tt>Hello.<br>
I am have trouble accessing an OOBTree.<br>
I have found several clues that indicate several different syntaxes,<br>
none of which work.<br>
Here are some of the things I've tried:<br>
<br>
</tt>=============================================================== <br>
<blockquote><tt>from BTrees.OOBTree import OOBTree</tt><br>
  <br>
  <tt>tree = OOBTree()</tt><br>
  <tt>tree['a'] = 'AAA'</tt><br>
</blockquote>
<tt>Gets:</tt><br>
<blockquote><tt>Error Type: TypeError</tt><br>
  <tt>Error Value: object does not support item or slice assignment<br>
  </tt></blockquote>
===============================================================<tt></tt>
<blockquote><tt>from BTrees.OOBTree import OOBTree</tt><br>
  <br>
  <tt>tree = OOBTree()</tt><br>
  <tt>tree.insert['a'] = 'AAA'</tt><br>
</blockquote>
<tt>Gets:</tt><br>
<blockquote><tt>Error Type: Unauthorized</tt><br>
  <tt>Error Value: You are not allowed to access insert in this context</tt><tt>&nbsp;</tt><br>
</blockquote>
=============================================================== <br>
<blockquote><tt>from BTrees.OOBTree import OOBTree</tt><br>
  <br>
  <tt>tree = OOBTree()</tt><br>
  <tt>insert(tree, 'a', 'AAA')</tt><br>
</blockquote>
<tt>Gets:</tt><br>
<blockquote><tt>Error Type: NameError</tt><br>
  <tt>Error Value: global name 'insert' is not defined</tt><br>
</blockquote>
=============================================================== <br>
<blockquote><tt>from BTrees.OOBTree import OOBTree</tt><br>
  <br>
  <tt>tree = OOBTree()</tt><br>
  <tt>OOBTree.insert(tree, 'a', 'AAA')</tt><br>
</blockquote>
<tt>Gets:</tt><br>
<blockquote><tt>Error Type: Unauthorized</tt><br>
  <tt>Error Value: You are not allowed to access insert in this context</tt><br>
</blockquote>
=============================================================== <br>
<br>
<tt>Also, I need to be able to access elements of the tree.&nbsp; <br>
Do I use has_key to check for existence of an element?&nbsp; <br>
I haven't been able to get it working either.&nbsp; <br>
Do I use<br>
&nbsp; &nbsp; Val = tree['a'] <br>
to retrieve the value?<br>
<br>
Third, how do I make my object persistent?<br>
I know that there is a Persistent package, but I don't know how to<br>
make my tree persistent.<br>
<br>
Thank you very much,<br>
Glen<br>
<br>
</tt>
</body>
</html>