Hi Jim,

I've not managed to link my orm event handlers with the model-glue
event context, but i do have them getting the current user id for
auditing.  I have a UserManager cfc which knows how to get the current
user id (from session or cookie or wherever), its created by
coldspring then a reference is placed at application.UserManager.  In
my preInsert/preUpdate methods i then call
application.UserManager.getCurrentUserID() and set the
created/updatedByUserID  properties accordingly

Its not as neat and tidy as i'd like, but it works.

To access the modelglue event context from outside the mg application
you could set a reference to the event in the request scope in mg's
onRequestStart handler, and then try to use that in your orm event
handlers.  I've know idea if it would work, and it feels like an awful
hack too..

Chris




On 9 November 2010 18:50, Jim Priest <[email protected]> wrote:
> I'm using the ORM event handler to write some audit information to the
> db when I insert/update.
>
> Brian Kotek has a nice post here:
> http://www.briankotek.com/blog/index.cfm/2010/9/10/Using-ColdFusion-ORM-and-HQL-Part-2-ORM-Event-Handler
>
> I have no idea however how to reference data stored in my MG event in
> those handlers.
>
> I have a "currentUser" object that has a user id I'd like to pass into
> my event handler.
>
>        public void function preUpdate( any entity, Struct oldData ) {
>                        local.timestamp = Now();
>                        arguments.entity.setupdateddate( local.timestamp );
>                        arguments.entity.setupdatedby( this should be my user 
> ID   );
>                }
>
> Any ideas?
> Jim
>
> --
> Model-Glue Sites:
> Home Page: http://www.model-glue.com
> Documentation: http://docs.model-glue.com
> Bug Tracker: http://bugs.model-glue.com
> Blog: http://www.model-glue.com/blog
>
> You received this message because you are subscribed to the Google
> Groups "model-glue" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en
>

-- 
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Reply via email to