Re: ERXThreadStorage and willUpdate()
Re: ERXThreadStorage and willUpdate()
- Subject: Re: ERXThreadStorage and willUpdate()
- From: Ramsey Gurley <email@hidden>
- Date: Mon, 4 Oct 2010 16:48:59 -0400
On Oct 4, 2010, at 4:22 PM, David Avendasora wrote:
Hi all,
We are moving from having to remember to manually set the modifiedBy
and modifiedDate values in our EOs when they are modified to
overriding willUpdate() and pulling the loggedInUser from
ERXThreadStorage.
We are overriding willUpdate() in our K12GenericRecord which all our
EOs extend.
for example (very simplified to get the point across) :
willUpdate() {
super.willUpdate();
setModifiedBy((SystemUser)
ERXThreadStorage.valueForKey("loggedInUser"));
}
As you can see, we are casting the results of the ThreadStorage as
SystemUser which itself is a subclass of K12GenericRecord.
It seems odd to be importing a subclass into it's own superclass,
but it since a SystemUser really is a standard EO and therefor is-a
K12GenericRecord, it also seems correct.
We're not doing anything horribly wrong here, are we?
Dave
I don't think that would cause a problem... but you could always use
an interface instead if it does.
You might also benefit by checking out the ERCore audit trail stuff.
That can do ec notification based auditing in the background without
touching any code in your EOs... It will automatically capture
modifiedBy, modifiedDate, type of modification(insert, update,
delete), the eo changed, and the changed values. And all you've got
to do is set the ERXAuditKeys in your model and register your user
class as the "actor" whenever your session awake()s. It's pretty
awesome stuff.
Ramsey
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden