Changing edit form based on user credentials

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing edit form based on user credentials

Michael Davies-3
Hi all,

I've got a class inherited from PRPage with some additional
properties, and I want to hide those properties from all but the page
owner at edit time. The problem is that PREditCommand doesn't pass the
context to the page before requesting its description, so the page
instance doesn't have the necessary information to dynamically change
its description.

I can get the required functionality to work, by overriding
PREditCommand>>description to make decisions about how to render the
page, but that seems I wonder if there's a better way to approach
this? In other words, is there a sensible way to make PRPage aware of
the context in which its edit form is being rendered? I was
contemplating adding context as an instance variable on PRPage and
setting it from PREditCommand, but I suspect that if that was a
sensible approach, it would have been done already!

I've only just started using Pier in earnest, so if this question
exposes a lack of understanding of anything fundamental, please feel
free to point this out.

Cheers,
Michael

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Changing edit form based on user credentials

Lukas Renggli-2
> I've got a class inherited from PRPage with some additional
> properties, and I want to hide those properties from all but the page
> owner at edit time. The problem is that PREditCommand doesn't pass the
> context to the page before requesting its description, so the page
> instance doesn't have the necessary information to dynamically change
> its description.

You can always get the current context using

        PRCurrentContext value

The expression might return nil if there is no current context, but in  
case of the execution of a command this should be defined.

> I've only just started using Pier in earnest, so if this question
> exposes a lack of understanding of anything fundamental, please feel
> free to point this out.

Good question. I added it to the upcoming FAQ:

        http://www.lukas-renggli.ch/smalltalk/pier/faq

If you have more things that you would like to see, please let me know.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Changing edit form based on user credentials

Michael Davies-3
On Thu, Aug 7, 2008 at 12:44 AM, Lukas Renggli <[hidden email]> wrote:
> You can always get the current context using
>
>        PRCurrentContext value
>

Exactly what I needed - it works perfectly now.

> If you have more things that you would like to see, please let me know.

If you keep answering 'em, I'll keep asking 'em!

Cheers,
Michael

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki