i Know Kung Foo Consulting

Using a Session Facade to handle evolving session variables

Last year I started at a company where two major projects were underway: Create a new payment application using Mach-II, then Redesign and overhaul the website. The payment application would have to work in both the current and upcoming versions of the website.

[More]


Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
jM's Gravatar Informative post. I _thought_ I understood it until I read your response here ;)
http://www.mail-archive.com/cfcdev@cfczone.org/msg...

<quote>
..Now we can safely output #request.SessionFacade.getUser.get*()# anywhere on the page. The session.user object is read using a lock inside SessionFacade.getUser().
</quote>

Can you explain how locking only SessionFacade.getUser() is safe? Shouldn't the facade also use locking when calling methods of the session.user object, like the facade in this post?

<cffunction name="getUserID" returntype="numeric" hint="Logged-in user's ID">
..
<cflock scope="session" type="readonly" timeout="1">
<!--- New object variable --->
<cfset userID = session.user.getUserID() />
</cflock>
..
</cffunction>
# Posted By jM | 3/17/07 4:06 PM
Adrian J. Moreno's Gravatar SessionFacade.getUser() uses a read-only lock to return session.user. Since the whole object has been returned under a lock, there's no need to place locks around the individual getters.
# Posted By Adrian J. Moreno | 3/19/07 11:35 PM
jM's Gravatar Then why not just use SessionFacade.getUser().getUserID() in FooGateway ? Or am I still missing something .. :)?
# Posted By jM | 3/20/07 2:01 PM
Adrian J. Moreno's Gravatar You aren't missing anything. I was. (D'oh!)

That last section of code had

WHERE userID = #variables.SessionFacade.getUserID()#

and has been updated to

WHERE userID = #variables.SessionFacade.getUser().getUserID()#

Sorry about that.
# Posted By Adrian J. Moreno | 3/20/07 3:17 PM
jM's Gravatar Good to know I may actually have a _few_ working brain cells left after all ;)
# Posted By jM | 3/20/07 3:30 PM
jM's Gravatar Btw - I just wanted to say thanks for writing this entry. I was definitely struggling with the whole session facade concept until I read it. Most of the articles I found were a little too abstract. This consise and concrete example really hit the spot!

Cheers
# Posted By jM | 3/20/07 3:45 PM

Copyright © 2001 - 2008 Adrian J. Moreno and i Know Kung Foo Consulting
BlogCFC was created by Raymond Camden. This blog is running version 5.9.001.