On Fri, 2009-06-26 at 12:52 +0200, Lukas Renggli wrote:
I'm toying
around with MAPluggableAccessor. While I really like
to introduce some kind of delegated descriptions it doesn't
work that easy. I'm not really familiar with caching of the
magritte descriptions. My problem is that I'm operating on
a MAContainerComponent using childAt: .
I don't have such a method.
Really? If this since ages and it seems to be your code :)
MAContainerComponent>>childAt: aDescription
^ children at: aDescription ifAbsent: [ nil ]
Ahh, I thought you refereed to MAContainerDescription. I have
#childAt: in MAContainerComponent too.
What you could try is to replace the Dictionary with an
IdentityDictionary in #buildChildren of MAContainerComponent. I am not
quite sure about all the consequences, but I guess it should solve
your problem.
Ok, I test it at least.
I don't understand the above part.
I was just wondering if I try to use the MAPluggableAccessor the
wrong way and hence facing problems. I can do
accessor
^ accessor ifNil: [
accessor := (MAPluggableAccessor
read: [:model|]
write: [:model :object| ]) ]
and then
descriptionThings
^ MAToManyRelationDescription
accessor: self accessor
label: 'Things'
priority: 10
This way I get it running but I don't like it much. I don't know exactly
what MANamedBuilder is caching. I just thought it might solve the
problem by caching the instances.
Why don't quite understand what you are trying to do? If you don't use
the accessor just don't assign one.
I must be more careful about how to do example code :) At the end the
blocks are of course not empty. Storing the accessor in an instance
variable gives me the identical accessor object with identical blocks.
This way the childAt: call succeeds.
The whole problem deals with tags. Until now I had several objects that
should be taggable. But as the code grew there were other things those
objects could have: comments, scores, etc.
Trying to solve this by inheritance is not possible for me. My idea now
is to treat tags more as meta data: The objects don't contain the data
anymore. At the moment I have any taggable object WHChallenge to that
I add
WHChallenge class>>descriptionTags
^ WHTag tagsDescription
WHTag class>>tagsDescription
^ (MAToManyRelationDescription
accessor: (MAPluggableAccessor
read: [:model|self tagsFor: model]
write: [:model :tags| self storeTags: tags for: model])
label: 'Tags'
priority: 40
)
classes: {WHTag};
reference: WHTag description;
componentClass: WHTagSelectComponent;
yourself
The WHTag classes holds all the tag instances. If this approach works
out I would try to solve this even more generic so that I can have a
common code base for this meta-data/annotation kind of things. All
other cases for comments, scores etc. should then be fairly easy
Norbert