Hello,
I have made a custom subclass of PULogin which will direct users to
their homepage after they login. The Commands widget in Pier then
shows both PULogin and my CustomLogin command. I'd like to hide
PULogin, so I thought I make PULogin invalid (isValidIn: aContext
returns false). Problem is that now I get CustomLogin listed twice in
the widget.
Here is the method, with some comments about what I think is going on
PRommandsWidget>>items
| commands command |
commands := self context commands. "These are all allowed commands"
^ Array
streamContents: [:stream | self commandClasses
"These are all possible commands"
do: [:class |
command := commands
detect: [:each | each = class
or: [each inheritsFrom: class]]
ifNone: [].
"command is an allowed command that is a subclass of any of
the command classes."
command isNil
ifFalse: [stream nextPut: command]]].
So it iterates over all possible commands (subclasses of PRCommand)
and adds allowed commands if they inherit from one of them.
My questions are:
- What's the point of the inheritance check?
- Shouldn't the list of commands in the widget be a subset of the
commands allowed in the context?
- Why shouldnt the widget just show the commands that the context allows?
I'd like to understand this before I patch it :-)
Cheers
Matthias