How to catch the moment of PRCase added to model?

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

How to catch the moment of PRCase added to model?

Dennis Schetinin
 guess I can do it using memento (by adding MACheckedMemento child with overloaded  #commit and accordingly overloading #mementoClass in my class). But maybe there is a simpler way?

... Thank you :)

--
Dennis Schetinin


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

Re: How to catch the moment of PRCase added to model?

Lukas Renggli
>  guess I can do it using memento (by adding MACheckedMemento child with
> overloaded  #commit and accordingly overloading #mementoClass in my class).
> But maybe there is a simpler way?

What do you mean by "added to model"?

Added as a child?

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: How to catch the moment of PRCase added to model?

Dennis Schetinin
>  guess I can do it using memento (by adding MACheckedMemento child with
> overloaded  #commit and accordingly overloading #mementoClass in my class).
> But maybe there is a simpler way?

What do you mean by "added to model"?

Added as a child?

Lukas

Yes, it was incorrect question. I mean the moment right after object's got it's aspects values after user filled the form and pressed 'Saved'... 

I mostly interested this moment right after new object was added. But it's quite obvious to implement.

I'm affraid it's still not clear... So, the whole task is to notify admin of the site (by email) when a new question (as an instance of PRCase) was added (for example). 

... Still sorry for my English

--
Dennis Schetinin


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

Re: How to catch the moment of PRCase added to model?

Lukas Renggli
> Yes, it was incorrect question. I mean the moment right after object's got
> it's aspects values after user filled the form and pressed 'Saved'...
> I mostly interested this moment right after new object was added. But it's
> quite obvious to implement.

You can override #write:using: in any model object to intercept the
writing of values.

At the moment there is no message though that is sent to the object
when all values are written. I guess, as you suggested, a new memento
could do this.

> I'm affraid it's still not clear... So, the whole task is to notify admin of
> the site (by email) when a new question (as an instance of PRCase) was
> added (for example).

This sounds more like a logging facility. PRImagePersistency already
writes a log of all changes on the site. Maybe this is of any help for
you?

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: How to catch the moment of PRCase added to model?

John McKeon
My first thought would be to use an override to doValidate or doExecute in PRAddCommand.
John

On Mon, Mar 30, 2009 at 3:03 AM, Lukas Renggli <[hidden email]> wrote:
> Yes, it was incorrect question. I mean the moment right after object's got
> it's aspects values after user filled the form and pressed 'Saved'...
> I mostly interested this moment right after new object was added. But it's
> quite obvious to implement.

You can override #write:using: in any model object to intercept the
writing of values.

At the moment there is no message though that is sent to the object
when all values are written. I guess, as you suggested, a new memento
could do this.

> I'm affraid it's still not clear... So, the whole task is to notify admin of
> the site (by email) when a new question (as an instance of PRCase) was
> added (for example).

This sounds more like a logging facility. PRImagePersistency already
writes a log of all changes on the site. Maybe this is of any help for
you?

Lukas

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


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: How to catch the moment of PRCase added to model?

keith1y
John McKeon wrote:
> My first thought would be to use an override to doValidate or
> doExecute in PRAddCommand.
> John
>
Pier could use a way to enable commands to be subclassable and
overridable. At present if you subclass PULogin for example, you get two
Login links showing up.

Keith


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

Re: How to catch the moment of PRCase added to model?

keith1y
In reply to this post by Lukas Renggli
Lukas Renggli wrote:

>> Yes, it was incorrect question. I mean the moment right after object's got
>> it's aspects values after user filled the form and pressed 'Saved'...
>> I mostly interested this moment right after new object was added. But it's
>> quite obvious to implement.
>>    
>
> You can override #write:using: in any model object to intercept the
> writing of values.
>
>  
If you load

Magritte-RealMemento (a dependent of Magritte-Scriptaculous) it implements:

Object:#commit:  - dummy implementation
 
and overrides

MACheckedMemento-#commit to send #commit: to the model.

It also has its own memento implementation which uses for the memento, a
copy of the original object (including behaviour) rather than a
dictionary of key-values.

I combine this with the client-framework, for pluggable front and back
ends. So commit: calls

self client autoCommitSomeObjectClass: self

and

#autoCommitSomeObjectClass: anObject

calls

db autoCommitSomeOnectClass: anObject

This gives you enough hooks to provide customisable behaviour
per-client-installation and per-database-backend, including mock
behaviour for testing.

Keith


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

Re: How to catch the moment of PRCase added to model?

Dennis Schetinin
Thanks all. Now I have enough information to make the decision. 

--
Dennis Schetinin


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