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 _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
> - What's the point of the inheritance check?
You are right, the inheritance check is completely useless in the current version of Pier. A few years ago the commands to add and edit different structure classes were different subclasses of an abstract add and edit command. Luckily this is no longer the case and therefor this method can be simplified to: PRCommandsWidget>>items | commands | commands := self context commands. ^ self commandClasses select: [ :each | commands includes: each ] I applied the same refactoring to PRViewsWidget which does the same unnecessary and complicated checks. > - Shouldn't the list of commands in the widget be a subset of the > commands allowed in the context? Exactly, this is what the new code is doing. It takes the selected classes in the selected order, and then removes all that are not useable in the current context. > - Why shouldnt the widget just show the commands that the context > allows? To allow people to customize (see the settings of the widget) what commands to show in what order. For example by using two different PRCommandsWidget's you can logically split commands like Login/Logout and Add/Edit/Remove page from each other. Name: Pier-Seaside-lr.191 Author: lr Time: 15 August 2007, 9:03:35 pm UUID: 86949e29-2ca2-438d-bb37-9e8faa2cd905 Ancestors: Pier-Seaside-lr.189 - Fixed PRCommandsWidget>>items and PRViewsWidget>>items that was doing far too much expecting a different command model that has been dropped from pier a long time ago - Kudos to Matthias Berth that reported this problem Cheers, Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Lukas,
thanks a lot, this makes it clear. On 8/15/07, Lukas Renggli <[hidden email]> wrote: > > - What's the point of the inheritance check? > > You are right, the inheritance check is completely useless in the > current version of Pier. [...] > > - Why shouldnt the widget just show the commands that the context > > allows? > > To allow people to customize (see the settings of the widget) what > commands to show in what order. For example by using two different > PRCommandsWidget's you can logically split commands like Login/Logout > and Add/Edit/Remove page from each other. OK , got that. Where are the settings of the widget? Are they accessible through the web somehow? Matthias _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
> On 8/15/07, Lukas Renggli <[hidden email]> wrote:
>>> - What's the point of the inheritance check? >> >> You are right, the inheritance check is completely useless in the >> current version of Pier. > [...] >>> - Why shouldnt the widget just show the commands that the context >>> allows? >> >> To allow people to customize (see the settings of the widget) what >> commands to show in what order. For example by using two different >> PRCommandsWidget's you can logically split commands like Login/Logout >> and Add/Edit/Remove page from each other. > > OK , got that. Where are the settings of the widget? Are they > accessible through the web somehow? There is a command called 'settings' available on all structures. Widgets usually have a lot of settings to customize their appearance. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Free forum by Nabble | Edit this page |