On 1/23/01, Zachary Bedell penned:
>It just seems to me that a more sensible solution could have been
>developed. Especially since this wasn't even a full version upgrade.
> If I go from version x.0 of a product to version y.0 of a product,
>then I'd expect some various little ugly things that would require
>fixing. But to go from x.0 to x.5 and have show-stopping code
>incompatibilities is kinda lame IM(NS)HO...
Well, after alot of wrangling and brainbusting, I've come up with a
scheme that works for me, using cfinclude, which stops 4.01 from
throwing an error when using the scope variable in a FALSE condition.
I've tested it on 4.51 and 4.01 and a simple variable change is all
that's needed.
<cfset whichversion = "4.0">
or
<cfset whichversion = "4.5">
Here is my application setting:
<CFPARAM NAME="application_name" DEFAULT="something_unique">
<cfapplication
name="#application_name#"
setclientcookies="yes"
sessionmanagement="yes"
sessiontimeout="#createtimespan(0,0,20,0)#">
<cfset whichversion = "4.5">
Here is my code block:
This uses a template named setmyname.cfm which is where I put the
code which uses session or application variables. This one is set to
use an exclusive lock with the session scope in 4.5 which is set in
the cflock_45.cfm template or the lock name
"something_unique_myname", which is set in the cflock_40.cfm template.
<cfset satemplate = "setmyname">
<cfset lockname="myname">
<cfset scopetype = "session">
<cfset locktype = "exclusive">
<cfset locktimeout = 20>
<cfinclude template="cflock.cfm">
This is the code within cflock.cfm
<CFIF whichversion IS "4.0">
<cfinclude template="cflock_40.cfm">
<cfelseif whichversion is "4.5">
<cfinclude template="cflock_45.cfm">
<cfelseif whichversion is "5.0">
<cfinclude template="cflock_50.cfm">
<cfelseif whichversion is "5.5">
<cfinclude template="cflock_55.cfm">
</cfif>
Notice, I'm ready for 2 more versions. LOL Even if they don't happen
to be 5.0 and 5.5, I can still use those numbers. Just set the
template name, use a single lock name for all sets of code using the
same session or application variables set to the scope type, and
whether it's exclusive or readonly and the timeout.
Here is the code in cflock_40.cfm and cflock_45.cfm:
4.0:
<cflock timeout="#locktimeout#" name="#application_name#_#lockname#"
type="#locktype#">
<cfinclude template="#scopetype#variables/#satemplate#.cfm">
</cflock>
4.5:
<cflock timeout="#locktimeout#" scope="#scopetype#" type="#locktype#">
<cfinclude template="#scopetype#variables/#satemplate#.cfm">
</cflock>
You can change the include template path of course, but I just made a
folder called sessionvariables and one called applicationvariables to
keep them separated.
Then I have templates that I pop into one of the variables
directories, such as setmyname.cfm with the actual code.
To see the exact same block of code, with just whichversion changed.
On Virtualscape running 4.51 and forced locking:
http://216.150.28.116/cflocktest/
On my server with 4.01
http://www.twcreations.com/cflocktest/
To download the templates and have a look:
http://www.twcreations.com/cflocktest/ftp/cflocktest.zip
If anyone has an easier way to do this or if you see something
glaringly wrong with this, I'm open for suggestion. :)
--
Bud Schneehagen - Tropical Web Creations
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ColdFusion Solutions / eCommerce Development
[EMAIL PROTECTED]
http://www.twcreations.com/
954.721.3452
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists