Magritte: adding a condition on the whole object in its description

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

Magritte: adding a condition on the whole object in its description

Matthias Berth-2
Hello,


I want to add a condition to a Magritte-described object that checks the whole object for consistency (and not just a single attribute). Is that possible?

Example: Think about creating a workgroup from some of the users of your site. The workgroup has a manager. The condition is that the manager must be one of the members of the workgroup.

I've tried to do this. I have two descriptions on the workgroup class side: one for the manager (saying that it can be any of the site's users) and one for the users (saying that this is a subset of all users). I can add a method #description to modify the standard description that is assembled from the description* methods on the class side. So I tried:

   Workgroup>>description
    ^super description
        addCondition: [:workgroup | workgroup users includes: workgroup manager]
        labelled: 'Manager must be a member of the workgroup';
        yourself

Alas, trying to edit an existing workgroup, I learned that the argument of the condition block is a MACheckedMemento, so I can't ask it for users.

What would be the best way to have this check everytime the work group is edited? Or should I just write the #manager: method such that the condition will be satisfied automatically?

Cheers

Matthias


PS: I want to say a big thank you, especially to Lukas, for the great answers on this list. I have learned something every time, and I was impressed when my questions on how to do something were answered with a patch.
PPS: No, this email is not a request for a patch :-)


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

RE: Magritte: adding a condition on the whole object in its description

Ramon Leon-5
> Subject: Magritte: adding a condition on the whole object in
> its description
>
> Hello,
>
> I want to add a condition to a Magritte-described object that
> checks the whole object for consistency (and not just a
> single attribute). Is that possible?
>
> Example: Think about creating a workgroup from some of the
> users of your site. The workgroup has a manager. The
> condition is that the manager must be one of the members of
> the workgroup.
>
> I've tried to do this. I have two descriptions on the
> workgroup class side: one for the manager (saying that it can
> be any of the site's users) and one for the users (saying
> that this is a subset of all users). I can add a method
> #description to modify the standard description that is
> assembled from the description* methods on the class side. So
> I tried:
>
>    Workgroup>>description
>     ^super description
>         addCondition: [:workgroup | workgroup users includes:
> workgroup manager]
>         labelled: 'Manager must be a member of the workgroup';
>         yourself
>
> Alas, trying to edit an existing workgroup, I learned that
> the argument of the condition block is a MACheckedMemento, so
> I can't ask it for users.
>
> What would be the best way to have this check everytime the
> work group is edited? Or should I just write the #manager:
> method such that the condition will be satisfied automatically?
>
> Cheers
> Matthias

See
http://onsmalltalk.com/programming/smalltalk/multiple-field-validation-rules
-in-magritte/ to see how to get at the values you're looking for, very
similar situation.

Ramon Leon
http://onsmalltalk.com


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

Re: Magritte: adding a condition on the whole object in its description

Matthias Berth-2
Thanks, that looks like exactly what I need :-)

Matthias

On 8/21/07, Ramon Leon <[hidden email]> wrote:
> Subject: Magritte: adding a condition on the whole object in
> its description
>
> Hello,
>
> I want to add a condition to a Magritte-described object that
> checks the whole object for consistency (and not just a
> single attribute). Is that possible?
>
> Example: Think about creating a workgroup from some of the

> users of your site. The workgroup has a manager. The
> condition is that the manager must be one of the members of
> the workgroup.
>
> I've tried to do this. I have two descriptions on the
> workgroup class side: one for the manager (saying that it can
> be any of the site's users) and one for the users (saying
> that this is a subset of all users). I can add a method
> #description to modify the standard description that is
> assembled from the description* methods on the class side. So
> I tried:
>
>    Workgroup>>description
>     ^super description
>         addCondition: [:workgroup | workgroup users includes:
> workgroup manager]
>         labelled: 'Manager must be a member of the workgroup';
>         yourself
>
> Alas, trying to edit an existing workgroup, I learned that
> the argument of the condition block is a MACheckedMemento, so
> I can't ask it for users.
>
> What would be the best way to have this check everytime the
> work group is edited? Or should I just write the #manager:
> method such that the condition will be satisfied automatically?
>
> Cheers
> Matthias

See
http://onsmalltalk.com/programming/smalltalk/multiple-field-validation-rules
-in-magritte/ to see how to get at the values you're looking for, very
similar situation.

Ramon Leon
http://onsmalltalk.com


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



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