Can't access objects in dictionary

Facundo Vozzi facundov79 at gmail.com
Thu Dec 30 19:48:32 UTC 2010


Hi Amir,
did you define #= method on User ?

I guest that It'll look like this:

User >> = otherUser
"Answer whether the receiver is equal to the argument."
 self class = otherUser class ifFalse: [^false].
^self name = otherUser name

You need implement the #hash method too:

User >> hash
"Answer a SmallInteger whose value is related to the receiver's identity."
 ^self name hash

Hope this help.

Facu


On Thu, Dec 30, 2010 at 10:24 AM, Amir Ansari <fractallyte at csi.com> wrote:

> I enter the following code in a Workspace:
> (the class 'User' is just a very simple class with instance variable
> 'username' and corresponding accessors)
>
>
> MagmaRepositoryController create: '/testDB' root: Dictionary new.
>
> initialSession := MagmaSession openLocal: '/testDB'.
> initialSession connectAs: 'admin'.
> initialSession commit: [ initialSession root at: 'users' put:
> MagmaPreallocatedDictionary new ].
> initialSession disconnect; closeRepository.
>
> newUser := User new username: 'Charlie'; yourself.
> newSession := MagmaSession openLocal: '/testDB'.
> newSession connectAs: 'charlie'.
> newSession commit: [ (newSession root at: 'users') at: newUser put:
> OrderedCollection new ].
> newSession disconnect; closeRepository.
>
> testSession := MagmaSession openLocal: '/testDB'.
> testSession connectAs: 'aUser'.
> (testSession root at: 'users') size
> (testSession root at: 'users') at: newUser
>
>
> 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.
>
> Am I doing something wrong...?
>
> Amir
> _______________________________________________
> Magma mailing list
> Magma at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/magma
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/magma/attachments/20101230/31a53316/attachment.htm


More information about the Magma mailing list