Event hooks

Aug 6, 2008 at 6:40 PM
I would like to execute functions when creating items, updating items and deleting items.
These functions can clean up related database-entries when hooking N2 to other systems or custom build systems or create pre-defined children when adding something.
Anyway, enough applications for them I'd say.

At this point I can override DateTime Updated but that get's triggered on adding and updating and deleting items, Overriding Created does not seem to work (the function is not called?) and I always miss the pointer to the item that the event is on...the itemID.
Is there a possibility in the current version to have these three hooks with a reference to the item they occur on or would it be possible to create this?
Perhaps as three argument attributes with the name of a function to be called (with a parameter itemID)?

I really could use this option for a wide variety of tasks when embedding N2 in a broader system...

Aug 6, 2008 at 10:30 PM
Have tried the events exposed by N2.Context.Current.Persister?
Aug 7, 2008 at 4:27 PM
trying...see http://www.codeplex.com/n2/Thread/View.aspx?ThreadId=32989 :-)
Aug 7, 2008 at 10:44 PM
It would be nice if there where ItemCreating, ItemCreated, ItemUpdating and ItemUpdated events.
I guess ItemSaving / ItemSaved is like ItemUpdating / ItemUpdated, but there is a difference in approach for newly created items...(insert vs. update).
When inserting other actions may need to be performed then when updating...
Is it possible to make the difference?

For everyone else, more info and code example on custom hooks here: http://www.codeplex.com/n2/Thread/View.aspx?ThreadId=32989