Re: D2W - execute custom code on save changes
Re: D2W - execute custom code on save changes
- Subject: Re: D2W - execute custom code on save changes
- From: Kieran Kelleher <email@hidden>
- Date: Tue, 14 Sep 2010 14:52:34 -0400
OK, so you can use any twisted logic you want to set a flag in ERXThreadStorage per request. Set the flag to true or false in some special logic in Session.awake maybe. I bet there is even a way to push a key in ERXThreadStorage using D2W rules based on certain logic ... maybe.
ERXThreadStorage is just a dictionary that is visible to the thread (a ThreadLocal variable) and works on the basis that each request/response is handled in a single thread. It gets cleared automatically at the end of a request. So you can push stuff in there anytime during a request and pull stuff out in totally unrelated places (for example in EOF), and still maintain separation of dependencies ... aka, not referring to appserver layer in the EOF layer. Very useful.
Regards, Kieran
On Sep 14, 2010, at 1:30 PM, Tim Worman wrote:
> Thanks Kieran. I'm gonna have to look into ERXThreadStorage. I know vaguely what it is for but haven't used it.
>
> In my case, the "doesRequireAuditTrail" will be less dependent on who the user is as what the Entity being edited is or what day it is. So, if I'm the user, the auditing may not happen today but may be required tomorrow.
>
> Thanks for your thoughts.
>
> Tim
>
> On Sep 14, 2010, at 10:21 AM, Kieran Kelleher wrote:
>
>> One suggestion:
>>
>> Have a boolean attribute on user entity "doesRequireAuditTrail" and turn it on/off for users that require auditing. Put your current user EOGlobalID in ERXThreadStorage (do that in Session awake) and check the user's setting in EO state transition methods will* or did* and log as needed.
>>
>> On Sep 14, 2010, at 12:56 PM, Tim Worman wrote:
>>
>>> I'm using ERModernDirectToWeb to re-implement some admin parts of my existing application. One of the criteria I have is that under certain circumstances I need to log saved changes for audit reasons. I don't have to do it all the time so I need to interrupt in there with some branching logic.
>>>
>>> The objects in question will be EO's so I thought about having the EO's themselves track the changes. The problem with that is that I really only want this auditing happening when accessing these EO's from the D2W admin interface. There are other processes that make changes to these EO's where I do not want the auditing.
>>>
>>> Does anyone have some suggestions or pointers about where I can look to implement something like this?
>>>
>>> Tim Worman
>>> UCLA GSE&IS
>>>
>>>
>>>
>>> _______________________________________________
>>> 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
>>
>
_______________________________________________
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