Hi Amir,<div>did you define #= method on User ? </div><div><br></div><div>I guest that It'll look like this:</div><div><br></div><div><div>User >> = otherUser</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>"Answer whether the receiver is equal to the argument."</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>self class = otherUser class ifFalse: [^false].</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>^self name = otherUser name</div>
<div><br></div><div>You need implement the #hash method too:</div><div><br></div><div>User >> hash</div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>"Answer a SmallInteger whose value is related to the receiver's identity."</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>^self name hash</div></div><div><br></div><div>Hope this help.</div><div><br></div>
<div>Facu</div><div><br></div><br><div class="gmail_quote">On Thu, Dec 30, 2010 at 10:24 AM, Amir Ansari <span dir="ltr"><<a href="mailto:fractallyte@csi.com">fractallyte@csi.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I enter the following code in a Workspace:<br>
(the class 'User' is just a very simple class with instance variable 'username' and corresponding accessors)<br>
<br>
<br>
MagmaRepositoryController create: '/testDB' root: Dictionary new.<br>
<br>
initialSession := MagmaSession openLocal: '/testDB'.<br>
initialSession connectAs: 'admin'.<br>
initialSession commit: [ initialSession root at: 'users' put: MagmaPreallocatedDictionary new ].<br>
initialSession disconnect; closeRepository.<br>
<br>
newUser := User new username: 'Charlie'; yourself.<br>
newSession := MagmaSession openLocal: '/testDB'.<br>
newSession connectAs: 'charlie'.<br>
newSession commit: [ (newSession root at: 'users') at: newUser put: OrderedCollection new ].<br>
newSession disconnect; closeRepository.<br>
<br>
testSession := MagmaSession openLocal: '/testDB'.<br>
testSession connectAs: 'aUser'.<br>
(testSession root at: 'users') size<br>
(testSession root at: 'users') at: newUser<br>
<br>
<br>
The last two lines indicate the problem: the size of the MagmaPreallocatedDictionary is reported correctly (even when I add more users), but when I try to access any of the entries with the 'User' objects as keys, I get a 'errorKeyNotFound:' error.<br>
<br>
Am I doing something wrong...?<br>
<br>
Amir<br>
_______________________________________________<br>
Magma mailing list<br>
<a href="mailto:Magma@lists.squeakfoundation.org">Magma@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/mailman/listinfo/magma" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/magma</a><br>
</blockquote></div><br></div>