Variables, scopes, and referencing, oh my

2012-12-19 Thread Scott Weikert

Lately I've been furiously modifying my main work project codebase, 
going through old (old!) code bits and reworking where I could, to 
modernize (i.e. take advantage of functions/tags that didn't exist back 
in the day) and/or just increase efficiency. I fully expect my keyboard 
to just say I've had enough and commit suicide any time now.

One of the things I've been dealing with is my past slackness re: 
variables and scopes, and the crossing of scopes. I've been tossing in 
Duplicate() around many scope/var bits when, say, setting a particular 
variable in an application scoped structure to equal an unscoped var, or 
a session scoped var.

The idea behind that is (and I'm sure I'm not telling anyone anything 
they don't know) is that a straight up application.var = session.var 
just creates a reference, and doesn't copy by value.

So - when running a particular script that uses variables in the 
app/session scopes, for example, is it all that crucial when going the 
other way? Is going with variables.var = application.var a bad thing, 
considering that application var is *not* likely to go away anytime 
soon? Or is it best practice to still copy by value?

In such a scenario, should that app scope var change in mid-stream for 
whatever reason (unlikely), I assume the variables scope var, being a 
reference, would reflect that change.

Assuming there's zero risk of said app scope var changing/vanishing over 
the execution time of the script, wouldn't the copy-by-reference be just 
a smidge less of a resource usage than copying by value?

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:353544
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-20 Thread Al Musella, DPM

Using url variables have an advantage in that you can bookmark the 
page and return to it or even share the page.
IF you want to hide them, you can use a form submission or even use ajax

At 04:10 PM 9/19/2011, you wrote:

@Jonah,

Thanks for the solution. Currently, I have been using the same way as you
suggested. Was just wondering if there a different way to do the same
instead of passing url variables on each page, like define once, use
everywhere. (in my case session/client scope have to be ruled out)

Thanks.

On Mon, Sep 19, 2011 at 12:10 PM, .jonah jonah@creori.com wrote:

 


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347542
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-20 Thread Larry Lyons

Or you can just do

Can we use Request scope in this type of situations?

Request is available to all templates within the request scope but it does not 
persist. If you want the variable to persist, use the session scope. However 
remember to use an exclusive lock when setting the variable. 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347543
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-19 Thread Steve 'Cutter' Blades

C'Mon Claude, store a 4 character value to the db, and hit the db for 
that value every time a session starts? Just use the cookie. If there's 
a lot of info, then sure, but don't add unnecessary overhead if you 
don't have to.

Steve 'Cutter' Blades
Adobe Community Professional
Adobe Certified Expert
Advanced Macromedia ColdFusion MX 7 Developer

http://cutterscrossing.com


Co-Author Learning Ext JS 3.2 Packt Publishing 2010
https://www.packtpub.com/learning-ext-js-3-2-for-building-dynamic-desktop-style-user-interfaces/book

The best way to predict the future is to help create it


On 9/18/2011 5:44 PM, =?ISO-8859-1?Q?Claude_Schn=E9egans wrote:
 I will need the values
 to be available for multiple browsers. I mean, the user might want to open a
 new browser using 'CTRL + N',

 This is actually not a new browser, but a new window in the same browser.
 Session variables are available in any window of the same browser.

 There is no need to save variables in a cookie, session is already maintained 
 through an id in a cookie.
 If you need to use the same variables across sessions, you will need to save 
 them in the database, set a cookie with some user id. With this id, you can 
 retreive the variables from the database.

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347513
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-19 Thread funand learning

Thanks for the replies. I got my scenario wrong I guess. So when the user
select a year say '2000' and proceeds to next page to see some data for that
year. then he clicks 'ctrl + n' to open new window. and now he wants to
select a different year say 2003 and want to see 2003 data. The purpose for
new window is to compare 2000 and 2003 data.

I see that session scope/client scope are not valid in this type of case.
Any thoughts?



On Mon, Sep 19, 2011 at 6:59 AM, Steve 'Cutter' Blades 
cold.fus...@cutterscrossing.com wrote:


 C'Mon Claude, store a 4 character value to the db, and hit the db for
 that value every time a session starts? Just use the cookie. If there's
 a lot of info, then sure, but don't add unnecessary overhead if you
 don't have to.

 Steve 'Cutter' Blades
 Adobe Community Professional
 Adobe Certified Expert
 Advanced Macromedia ColdFusion MX 7 Developer
 
 http://cutterscrossing.com


 Co-Author Learning Ext JS 3.2 Packt Publishing 2010

 https://www.packtpub.com/learning-ext-js-3-2-for-building-dynamic-desktop-style-user-interfaces/book

 The best way to predict the future is to help create it


 On 9/18/2011 5:44 PM, =?ISO-8859-1?Q?Claude_Schn=E9egans wrote:
  I will need the values
  to be available for multiple browsers. I mean, the user might want to
 open a
  new browser using 'CTRL + N',
 
  This is actually not a new browser, but a new window in the same
 browser.
  Session variables are available in any window of the same browser.
 
  There is no need to save variables in a cookie, session is already
 maintained through an id in a cookie.
  If you need to use the same variables across sessions, you will need to
 save them in the database, set a cookie with some user id. With this id, you
 can retreive the variables from the database.
 
 

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347516
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-19 Thread Russ Michaels

session scope is perfectly valid in this case, either by requiring the
form to be submitted or by using AJAX to autosave form fields when
they change.
You just need to make sure the data is saved before opening a new window.
Alternately you could just pass the values to the new window via
Javascript on on the URL as a querystring.


On Mon, Sep 19, 2011 at 3:07 PM, funand learning
funandlrnn...@gmail.com wrote:

 Thanks for the replies. I got my scenario wrong I guess. So when the user
 select a year say '2000' and proceeds to next page to see some data for that
 year. then he clicks 'ctrl + n' to open new window. and now he wants to
 select a different year say 2003 and want to see 2003 data. The purpose for
 new window is to compare 2000 and 2003 data.

 I see that session scope/client scope are not valid in this type of case.
 Any thoughts?



 On Mon, Sep 19, 2011 at 6:59 AM, Steve 'Cutter' Blades 
 cold.fus...@cutterscrossing.com wrote:


 C'Mon Claude, store a 4 character value to the db, and hit the db for
 that value every time a session starts? Just use the cookie. If there's
 a lot of info, then sure, but don't add unnecessary overhead if you
 don't have to.

 Steve 'Cutter' Blades
 Adobe Community Professional
 Adobe Certified Expert
 Advanced Macromedia ColdFusion MX 7 Developer
 
 http://cutterscrossing.com


 Co-Author Learning Ext JS 3.2 Packt Publishing 2010

 https://www.packtpub.com/learning-ext-js-3-2-for-building-dynamic-desktop-style-user-interfaces/book

 The best way to predict the future is to help create it


 On 9/18/2011 5:44 PM, =?ISO-8859-1?Q?Claude_Schn=E9egans wrote:
      I will need the values
  to be available for multiple browsers. I mean, the user might want to
 open a
  new browser using 'CTRL + N',
 
  This is actually not a new browser, but a new window in the same
 browser.
  Session variables are available in any window of the same browser.
 
  There is no need to save variables in a cookie, session is already
 maintained through an id in a cookie.
  If you need to use the same variables across sessions, you will need to
 save them in the database, set a cookie with some user id. With this id, you
 can retreive the variables from the database.
 
 



 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347517
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-19 Thread Claude Schnéegans

 C'Mon Claude, store a 4 character value to the db

If the Tax year is the ONLY information needed, then a cookie may be used.
But in my mind, there are often more informations to store about the user,
like his name, eMail, address, etc. Then the database approach is better.



~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347518
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-19 Thread funand learning

@Russ. I am not sure I understand what you are saying.

if my index.cfm is as follows:

cfset StructClear(session)

form name=frm method=post action=results.cfm
 select name=dd_year
option value=20002000/option
option value=20012001/option
option value=20022002/option
option value=20032003/option
 /select
 input type=submit value=Submit name=sbtbutton /
/form
The second page is as follows:
*results.cfm*
cfset structappend(session,form)
cfdump var=#session#
a href=onemorepage.cfmGo to next page/a

*onemorepage.cfm*
cfdump var=#session#
a href=index.cfmGo to search page/a

I have application.cfm too which has the following line:

CFAPPLICATION
NAME=myapp
setclientcookies=Yes
clientmanagement=Yes
sessionmanagement=Yes
sessiontimeout=#CreateTimeSpan(1,0,0,0)#
applicationtimeout=#CreateTimeSpan(1,0,0,0)#

so now the user is on 'onemorepage.cfm' and from here he opens a new window
using 'ctrl + N'. On new window he clicks on 'Go to search page' link, and
then select a dfferent tax year. Now, I want the old window to show the old
tax year for all pages, and new window to show new tax year for all pages.

I tested using both session/client. The problem is If I select a different
tax year on new window, and then refresh the old window, the old
window shows the new value

I hope I am clear.


On Mon, Sep 19, 2011 at 10:23 AM,  wrote:


  C'Mon Claude, store a 4 character value to the db

 If the Tax year is the ONLY information needed, then a cookie may be used.
 But in my mind, there are often more informations to store about the user,
 like his name, eMail, address, etc. Then the database approach is better.



 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347519
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-19 Thread Russ Michaels

session variables can only be set on the server, a form only exists in
HTML if you are not submitting the form then nothing is being sent to
the server for you to store in any scope.
Therefore you will either need to pass the current form field values
between your windows using Javascript or you will need to use AJAX to
store the current selection in session scope so that you can then
access it on the new window.

Russ

On Mon, Sep 19, 2011 at 4:10 PM, funand learning
funandlrnn...@gmail.com wrote:

 @Russ. I am not sure I understand what you are saying.

 if my index.cfm is as follows:

 cfset StructClear(session)

 form name=frm method=post action=results.cfm
  select name=dd_year
    option value=20002000/option
    option value=20012001/option
    option value=20022002/option
    option value=20032003/option
  /select
  input type=submit value=Submit name=sbtbutton /
 /form
 The second page is as follows:
 *results.cfm*
 cfset structappend(session,form)
 cfdump var=#session#
 a href=onemorepage.cfmGo to next page/a

 *onemorepage.cfm*
 cfdump var=#session#
 a href=index.cfmGo to search page/a

 I have application.cfm too which has the following line:

 CFAPPLICATION
 NAME=myapp
 setclientcookies=Yes
 clientmanagement=Yes
 sessionmanagement=Yes
 sessiontimeout=#CreateTimeSpan(1,0,0,0)#
 applicationtimeout=#CreateTimeSpan(1,0,0,0)#

 so now the user is on 'onemorepage.cfm' and from here he opens a new window
 using 'ctrl + N'. On new window he clicks on 'Go to search page' link, and
 then select a dfferent tax year. Now, I want the old window to show the old
 tax year for all pages, and new window to show new tax year for all pages.

 I tested using both session/client. The problem is If I select a different
 tax year on new window, and then refresh the old window, the old
 window shows the new value

 I hope I am clear.


 On Mon, Sep 19, 2011 at 10:23 AM,  wrote:


  C'Mon Claude, store a 4 character value to the db

 If the Tax year is the ONLY information needed, then a cookie may be used.
 But in my mind, there are often more informations to store about the user,
 like his name, eMail, address, etc. Then the database approach is better.





 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347520
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-19 Thread Michael Grant

Or, you could just use js (be it vanilla or a framework like jQuery) to set
a cookie when the onChange event of the drop down menu is fired? Unless I
misunderstand, it sounds like it doesn't really need to be in the users
session.


On Mon, Sep 19, 2011 at 11:15 AM, Russ Michaels r...@michaels.me.uk wrote:


 session variables can only be set on the server, a form only exists in
 HTML if you are not submitting the form then nothing is being sent to
 the server for you to store in any scope.
 Therefore you will either need to pass the current form field values
 between your windows using Javascript or you will need to use AJAX to
 store the current selection in session scope so that you can then
 access it on the new window.

 Russ

 On Mon, Sep 19, 2011 at 4:10 PM, funand learning
 funandlrnn...@gmail.com wrote:
 
  @Russ. I am not sure I understand what you are saying.
 
  if my index.cfm is as follows:
 
  cfset StructClear(session)
 
  form name=frm method=post action=results.cfm
   select name=dd_year
 option value=20002000/option
 option value=20012001/option
 option value=20022002/option
 option value=20032003/option
   /select
   input type=submit value=Submit name=sbtbutton /
  /form
  The second page is as follows:
  *results.cfm*
  cfset structappend(session,form)
  cfdump var=#session#
  a href=onemorepage.cfmGo to next page/a
 
  *onemorepage.cfm*
  cfdump var=#session#
  a href=index.cfmGo to search page/a
 
  I have application.cfm too which has the following line:
 
  CFAPPLICATION
  NAME=myapp
  setclientcookies=Yes
  clientmanagement=Yes
  sessionmanagement=Yes
  sessiontimeout=#CreateTimeSpan(1,0,0,0)#
  applicationtimeout=#CreateTimeSpan(1,0,0,0)#
 
  so now the user is on 'onemorepage.cfm' and from here he opens a new
 window
  using 'ctrl + N'. On new window he clicks on 'Go to search page' link,
 and
  then select a dfferent tax year. Now, I want the old window to show the
 old
  tax year for all pages, and new window to show new tax year for all
 pages.
 
  I tested using both session/client. The problem is If I select a
 different
  tax year on new window, and then refresh the old window, the old
  window shows the new value
 
  I hope I am clear.
 
 
  On Mon, Sep 19, 2011 at 10:23 AM,  wrote:
 
 
   C'Mon Claude, store a 4 character value to the db
 
  If the Tax year is the ONLY information needed, then a cookie may be
 used.
  But in my mind, there are often more informations to store about the
 user,
  like his name, eMail, address, etc. Then the database approach is
 better.
 
 
 
 
 
 

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347521
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-19 Thread .jonah

Ok, that wasn't clear in the beginning.

You want to keep track of DIFFERENT years in each window. Since they're 
both in the same browser and visiting the same site, they'll be 
receiving the same cookies and therefore the same session.

To do this you'll probably need to pass the year along in the URL as you 
go from page-to-page.

On 9/19/11 8:10 AM, funand learning wrote:
 @Russ. I am not sure I understand what you are saying.

 if my index.cfm is as follows:

 cfset StructClear(session)

 form name=frm method=post action=results.cfm
   select name=dd_year
  option value=20002000/option
  option value=20012001/option
  option value=20022002/option
  option value=20032003/option
   /select
   input type=submit value=Submit name=sbtbutton /
 /form
 The second page is as follows:
 *results.cfm*
 cfset structappend(session,form)
 cfdump var=#session#
 a href=onemorepage.cfmGo to next page/a

 *onemorepage.cfm*
 cfdump var=#session#
 a href=index.cfmGo to search page/a

 I have application.cfm too which has the following line:

 CFAPPLICATION
 NAME=myapp
 setclientcookies=Yes
 clientmanagement=Yes
 sessionmanagement=Yes
 sessiontimeout=#CreateTimeSpan(1,0,0,0)#
 applicationtimeout=#CreateTimeSpan(1,0,0,0)#

 so now the user is on 'onemorepage.cfm' and from here he opens a new window
 using 'ctrl + N'. On new window he clicks on 'Go to search page' link, and
 then select a dfferent tax year. Now, I want the old window to show the old
 tax year for all pages, and new window to show new tax year for all pages.

 I tested using both session/client. The problem is If I select a different
 tax year on new window, and then refresh the old window, the old
 window shows the new value

 I hope I am clear.


 On Mon, Sep 19, 2011 at 10:23 AM,  wrote:

   C'Mon Claude, store a 4 character value to the db

 If the Tax year is the ONLY information needed, then a cookie may be used.
 But in my mind, there are often more informations to store about the user,
 like his name, eMail, address, etc. Then the database approach is better.




 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347522
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-19 Thread funand learning

@Jonah,

Thanks for the solution. Currently, I have been using the same way as you
suggested. Was just wondering if there a different way to do the same
instead of passing url variables on each page, like define once, use
everywhere. (in my case session/client scope have to be ruled out)

Thanks.

On Mon, Sep 19, 2011 at 12:10 PM, .jonah jonah@creori.com wrote:


 Ok, that wasn't clear in the beginning.

 You want to keep track of DIFFERENT years in each window. Since they're
 both in the same browser and visiting the same site, they'll be
 receiving the same cookies and therefore the same session.

 To do this you'll probably need to pass the year along in the URL as you
 go from page-to-page.

 On 9/19/11 8:10 AM, funand learning wrote:
  @Russ. I am not sure I understand what you are saying.
 
  if my index.cfm is as follows:
 
  cfset StructClear(session)
 
  form name=frm method=post action=results.cfm
select name=dd_year
   option value=20002000/option
   option value=20012001/option
   option value=20022002/option
   option value=20032003/option
/select
input type=submit value=Submit name=sbtbutton /
  /form
  The second page is as follows:
  *results.cfm*
  cfset structappend(session,form)
  cfdump var=#session#
  a href=onemorepage.cfmGo to next page/a
 
  *onemorepage.cfm*
  cfdump var=#session#
  a href=index.cfmGo to search page/a
 
  I have application.cfm too which has the following line:
 
  CFAPPLICATION
  NAME=myapp
  setclientcookies=Yes
  clientmanagement=Yes
  sessionmanagement=Yes
  sessiontimeout=#CreateTimeSpan(1,0,0,0)#
  applicationtimeout=#CreateTimeSpan(1,0,0,0)#
 
  so now the user is on 'onemorepage.cfm' and from here he opens a new
 window
  using 'ctrl + N'. On new window he clicks on 'Go to search page' link,
 and
  then select a dfferent tax year. Now, I want the old window to show the
 old
  tax year for all pages, and new window to show new tax year for all
 pages.
 
  I tested using both session/client. The problem is If I select a
 different
  tax year on new window, and then refresh the old window, the old
  window shows the new value
 
  I hope I am clear.
 
 
  On Mon, Sep 19, 2011 at 10:23 AM,  wrote:
 
C'Mon Claude, store a 4 character value to the db
 
  If the Tax year is the ONLY information needed, then a cookie may be
 used.
  But in my mind, there are often more informations to store about the
 user,
  like his name, eMail, address, etc. Then the database approach is
 better.
 
 
 
 
 

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347526
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Question on scopes

2011-09-18 Thread fun and learning

Hi All- 

I have a question on variable scopes. I have the following scenario.

Suppose I have a dropdown as below with some tax years:

form name=frm method=post action=results.cfm
 select name=dd_year
 option value=20002000/option
 option value=20012001/option
 option value=20022002/option
 option value=20032003/option
 /select

 input type=submit value=Submit name=sbtbutton /

/form

So once the user logins and selects a year from the drop down, upon clicking 
the submit button, the year value should be available across all pages. What is 
the best way to store the value? I mean in which scope?

Thanks. 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347501
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-18 Thread Claude Schnéegans

 What is the best way to store the value? I mean in which scope?

Definitely in the session scope.

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347502
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-18 Thread Steve 'Cutter' Blades

In you submit handler template, apply the FORM.dd_year value to a 
SESSION scope variable. This keeps that variable uniquer per user, and 
persists it throughout their browsing session. The other option is to 
set it to the COOKIE scope, so that it might be available for that user 
across sessions. Remember to param/cfparam the variable on any page it 
might be used, so that you can apply a default if the value has not 
explicitly been set yet.

cfparam type=numeric name=COOKIE.birthYear default=0 /

select name=dd_year
cfloop from=2000 to=2003 index=REQUEST.i
option value=#REQUEST.i#cfif COOKIE.birthYear eq REQUEST.i 
selected=selected/cfif#REQUEST.i#/option
/cfloop
/select

Steve 'Cutter' Blades
Adobe Community Professional
Adobe Certified Expert
Advanced Macromedia ColdFusion MX 7 Developer

http://cutterscrossing.com


Co-Author Learning Ext JS 3.2 Packt Publishing 2010
https://www.packtpub.com/learning-ext-js-3-2-for-building-dynamic-desktop-style-user-interfaces/book

The best way to predict the future is to help create it


On 9/18/2011 2:04 PM, fun and learning wrote:
 Hi All-

 I have a question on variable scopes. I have the following scenario.

 Suppose I have a dropdown as below with some tax years:

 form name=frm method=post action=results.cfm
   select name=dd_year
   option value=20002000/option
   option value=20012001/option
   option value=20022002/option
   option value=20032003/option
   /select

   input type=submit value=Submit name=sbtbutton /

 /form

 So once the user logins and selects a year from the drop down, upon clicking 
 the submit button, the year value should be available across all pages. What 
 is the best way to store the value? I mean in which scope?

 Thanks.

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347503
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-18 Thread Phillip Vector

Or you can just do

cfset session.dd_year = form.dd_year

I swear.. Sometimes, people make things more convoluted then they have to. :)

On Sun, Sep 18, 2011 at 11:18 AM, Steve 'Cutter' Blades
cold.fus...@cutterscrossing.com wrote:

 In you submit handler template, apply the FORM.dd_year value to a
 SESSION scope variable. This keeps that variable uniquer per user, and
 persists it throughout their browsing session. The other option is to
 set it to the COOKIE scope, so that it might be available for that user
 across sessions. Remember to param/cfparam the variable on any page it
 might be used, so that you can apply a default if the value has not
 explicitly been set yet.

 cfparam type=numeric name=COOKIE.birthYear default=0 /

 select name=dd_year
 cfloop from=2000 to=2003 index=REQUEST.i
 option value=#REQUEST.i#cfif COOKIE.birthYear eq REQUEST.i
 selected=selected/cfif#REQUEST.i#/option
 /cfloop
 /select

 Steve 'Cutter' Blades
 Adobe Community Professional
 Adobe Certified Expert
 Advanced Macromedia ColdFusion MX 7 Developer
 
 http://cutterscrossing.com


 Co-Author Learning Ext JS 3.2 Packt Publishing 2010
 https://www.packtpub.com/learning-ext-js-3-2-for-building-dynamic-desktop-style-user-interfaces/book

 The best way to predict the future is to help create it


 On 9/18/2011 2:04 PM, fun and learning wrote:
 Hi All-

 I have a question on variable scopes. I have the following scenario.

 Suppose I have a dropdown as below with some tax years:

 form name=frm method=post action=results.cfm
   select name=dd_year
       option value=20002000/option
       option value=20012001/option
       option value=20022002/option
       option value=20032003/option
   /select

   input type=submit value=Submit name=sbtbutton /

 /form

 So once the user logins and selects a year from the drop down, upon clicking 
 the submit button, the year value should be available across all pages. What 
 is the best way to store the value? I mean in which scope?

 Thanks.



 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347504
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-18 Thread fun and learning

Or you can just do

cfset session.dd_year = form.dd_year

I swear.. Sometimes, people make things more convoluted then they have to. :)

On Sun, Sep 18, 2011 at 11:18 AM, Steve 'Cutter' Blades
cold.fus...@cutterscrossing.com wrote:


Can we use Request scope in this type of situations? 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347505
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-18 Thread Matt Quackenbush

I would recommend purchasing a CFWACK book and reading through all of the
basic documentation.  These questions are fundamental to using CF, and
without a clear understanding of the answers you are wasting your time and
everyone else's.  That may sound harsh, but it's the truth.  The FREE
documentation can teach you about this stuff in a matter of hours - or
perhaps minutes, depending upon how fast you read.

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/index.html

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7fd5.html

HTH


On Sun, Sep 18, 2011 at 1:54 PM, fun and learning
funandlrnn...@gmail.comwrote:


 Or you can just do
 
 cfset session.dd_year = form.dd_year
 
 I swear.. Sometimes, people make things more convoluted then they have to.
 :)
 
 On Sun, Sep 18, 2011 at 11:18 AM, Steve 'Cutter' Blades
 cold.fus...@cutterscrossing.com wrote:
 

 Can we use Request scope in this type of situations?

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347506
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-18 Thread Phillip Vector

Why?

On Sun, Sep 18, 2011 at 11:54 AM, fun and learning
funandlrnn...@gmail.com wrote:

Or you can just do

cfset session.dd_year = form.dd_year

I swear.. Sometimes, people make things more convoluted then they have to. :)

On Sun, Sep 18, 2011 at 11:18 AM, Steve 'Cutter' Blades
cold.fus...@cutterscrossing.com wrote:


 Can we use Request scope in this type of situations?

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347507
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-18 Thread .jonah

On 9/18/11 11:54 AM, fun and learning wrote:
 Or you can just do

 cfset session.dd_year = form.dd_year
Yes, in the form submission handler, but you'll need to param 
session.dd_year otherwise your output will fail until you submit the form.

cfparam type=numeric name=session.dd_year default= /

 Can we use Request scope in this type of situations?
No, the request scope only lives for a single page load, everything is 
gone when the page is sent to the browser.

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347508
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-18 Thread funand learning

Thanks for the answer. Between session, client and cookie, I think i will
have to use client/cookie to store the values because I will need the values
to be available for multiple browsers. I mean, the user might want to open a
new browser using 'CTRL + N', so the value of tax year on new window should
be the same as the one selected on the old window.

One last question is:  which is the better option between Client and cookie?

On Sun, Sep 18, 2011 at 3:07 PM, .jonah jonah@creori.com wrote:


 On 9/18/11 11:54 AM, fun and learning wrote:
  Or you can just do
 
  cfset session.dd_year = form.dd_year
 Yes, in the form submission handler, but you'll need to param
 session.dd_year otherwise your output will fail until you submit the form.

 cfparam type=numeric name=session.dd_year default= /

  Can we use Request scope in this type of situations?
 No, the request scope only lives for a single page load, everything is
 gone when the page is sent to the browser.

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347509
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-18 Thread .jonah

For something simple like that, I'd store it in the user's prefs in the 
session scope. That way you don't have to set another cookie - the cf 
session cookie already exists. You may want to store the value with the 
user's account / login / etc. so it'll hang around longer.

Client Scope is a nice concept but the problems are many in the current 
implementation:
http://www.dopefly.com/pages/ColdFusionClientVariablesFinalNail.cfm
http://www.petefreitag.com/item/406.cfm

On 9/18/11 12:21 PM, funand learning wrote:
 Thanks for the answer. Between session, client and cookie, I think i will
 have to use client/cookie to store the values because I will need the values
 to be available for multiple browsers. I mean, the user might want to open a
 new browser using 'CTRL + N', so the value of tax year on new window should
 be the same as the one selected on the old window.

 One last question is:  which is the better option between Client and cookie?

 On Sun, Sep 18, 2011 at 3:07 PM, .jonahjonah@creori.com  wrote:

 On 9/18/11 11:54 AM, fun and learning wrote:
 Or you can just do

 cfset session.dd_year = form.dd_year
 Yes, in the form submission handler, but you'll need to param
 session.dd_year otherwise your output will fail until you submit the form.

 cfparam type=numeric name=session.dd_year default= /

 Can we use Request scope in this type of situations?
 No, the request scope only lives for a single page load, everything is
 gone when the page is sent to the browser.


 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347510
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-18 Thread Russ Michaels

I'm not sure how you got the idea that session vars would not work in
some browsers, but this is not the case.
All coldfusion variables exist only on the server so the browser is immaterial.
A cookie will be saved to identify your session and thus which tells
CF which session variables to use.

If you want to save form details for later use by the user, i.e.
allowing them to edit them later or pass them between pages, then
sessions cope is the best way.

If you want to store a single value then
cfset session.myvar = form.myvar is the best

If you want to store an entire form then do


cfset session.myform = structcopy(form)

then you have all the form fields available to you.
This is a quick and simple way to allow users to return to forms and
pre-populate them with previously submitted values.

Matt Quacks response was a bit harsh, but if you are a beginner, the
CFWHACK books are good.
--

Russ Michaels

www.bluethunderinternet.com  : Business hosting services  solutions
www.cfmldeveloper.com    : ColdFusion developer community
www.michaels.me.uk   : my blog
www.cfsearch.com : ColdFusion search engine

sky

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347511
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Question on scopes

2011-09-18 Thread Claude Schnéegans

  I will need the values
to be available for multiple browsers. I mean, the user might want to open a
new browser using 'CTRL + N',

This is actually not a new browser, but a new window in the same browser.
Session variables are available in any window of the same browser.

There is no need to save variables in a cookie, session is already maintained 
through an id in a cookie.
If you need to use the same variables across sessions, you will need to save 
them in the database, set a cookie with some user id. With this id, you can 
retreive the variables from the database.

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347512
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Minor confusion on variable scopes

2009-11-02 Thread Stefan Richter

I'm trying to set a few variables in my Application.cfc file and I'm a  
bit confused about scopes.

Here's what I have got:

   cffunction name=onApplicationStart

 cfset APPLICATION.page_title = My Title
cfreturn True

/cffunction


I can access this anywhere in my site as #APPLICATION.page_title#. But  
if I leave off the APPLICATION and write
  cfset page_title = My Title and then try to access a variable  
#page_title# CF9 throws an error, saying the variable is not defined  
(I restarted CF before testing this).
Variable PAGE_TITLE is undefined.



Why does this happen? Do I really need to prefix all variables with  
APPLICATION? According to the debugger a variable defined in  
Application.cfc without the APPLICATION prefix does not exist in any  
scope.

Stefan




~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:327897
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Minor confusion on variable scopes

2009-11-02 Thread Jason Fisher

Yes, in the methods of Application.cfc, you need to specify the scope, 
including the Application scope.  For Application attributes 
(sessiontimeout, name, etc), you can specify those in the THIS scope, 
but only outside the methods:

cfcomponent
cfset this.name = myApp /
cfset this.sessionManagment = true /
...

But even Application attributes have to be scoped inside the 
onApplicationStart method:

cffunction name=onApplicationStart
cfset application.name = myApp /
...



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:327898
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Minor confusion on variable scopes

2009-11-02 Thread Stefan Richter

Thanks for clearing that up Jason.


On 2 Nov 2009, at 11:50, Jason Fisher wrote:


 Yes, in the methods of Application.cfc, you need to specify the scope,
 including the Application scope.  For Application attributes
 (sessiontimeout, name, etc), you can specify those in the THIS scope,
 but only outside the methods:

 cfcomponent
 cfset this.name = myApp /
 cfset this.sessionManagment = true /
 ...

 But even Application attributes have to be scoped inside the
 onApplicationStart method:

 cffunction name=onApplicationStart
 cfset application.name = myApp /
 ...


~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:327899
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Minor confusion on variable scopes

2009-11-02 Thread Dominic Watson

I had this question in a job interview once, 'which Application.cfc method
shares the variables scope with the rest of the application?'. I, of course,
said, 'none of them do, the variables scope is local to the application' and
they said that the correct answer was 'onRequest' - total hogwash.

The variables scope *is* local to the cfc. However, you can use the
OnRequest method to include the requested template, which means that all
your code is now local to the cfc instance and shares its variables scope.
So:

cffunction name=onRequest output=true returnType=void
access=public
cfargument name=targetPage type=String required=true /
cfinclude template=#arguments.targetPage# /
/cffunction

HTH

Dominic

2009/11/2 Stefan Richter ste...@flashcomguru.com


 I'm trying to set a few variables in my Application.cfc file and I'm a
 bit confused about scopes.

 Here's what I have got:

   cffunction name=onApplicationStart

 cfset APPLICATION.page_title = My Title
cfreturn True

 /cffunction


 I can access this anywhere in my site as #APPLICATION.page_title#. But
 if I leave off the APPLICATION and write
  cfset page_title = My Title and then try to access a variable
 #page_title# CF9 throws an error, saying the variable is not defined
 (I restarted CF before testing this).
 Variable PAGE_TITLE is undefined.



 Why does this happen? Do I really need to prefix all variables with
 APPLICATION? According to the debugger a variable defined in
 Application.cfc without the APPLICATION prefix does not exist in any
 scope.

 Stefan




 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:327900
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Custom scopes

2009-09-21 Thread Rick Sanders

Hey All. Quick question, can I define custom scopes for my variables in CF?

 

Example:

cfset myscope.var = myvar

 

I've searched the documentation and didn't see anything on it.

 

Thanks,

 

Rick Sanders

Webenergy

Canada: 902-431-7279

USA:   919-799-9076

Canada: www.webenergy.ca

USA:   www.webenergyusa.com

 





~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326456
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Custom scopes

2009-09-21 Thread Alan Rother

Of course.
However... what you have really done is create a variable called

variables.myscope.var


=]

-- 
Alan Rother
Adobe Certified Advanced ColdFusion MX 7 Developer
Manager, Phoenix Cold Fusion User Group, AZCFUG.org


~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326457
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Custom scopes

2009-09-21 Thread Gerald Guido

cfset myscope =  structnew()
cfset myscope.var = myvar

HTH
G!

On Mon, Sep 21, 2009 at 12:44 PM, Rick Sanders r...@webenergy.ca wrote:


 Hey All. Quick question, can I define custom scopes for my variables in CF?



 Example:

 cfset myscope.var = myvar



 I've searched the documentation and didn't see anything on it.



 Thanks,



 Rick Sanders

 Webenergy

 Canada: 902-431-7279

 USA:   919-799-9076

 Canada: www.webenergy.ca

 USA:   www.webenergyusa.com







 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326458
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Custom scopes

2009-09-21 Thread Charlie Griefer

In other words, you're implicitly creating a structure called 'myscope' with
a key called 'var' (and then that structure gets put into the
local/variables scope anyways).

On Mon, Sep 21, 2009 at 9:46 AM, Alan Rother alan.rot...@gmail.com wrote:


 Of course.
 However... what you have really done is create a variable called

 variables.myscope.var


 =]

 --
 Alan Rother
 Adobe Certified Advanced ColdFusion MX 7 Developer
 Manager, Phoenix Cold Fusion User Group, AZCFUG.org


 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326459
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Custom scopes

2009-09-21 Thread Rick Sanders

Thanks. Makes sense I have to create the scope before assigning a var to it!

-Original Message-
From: Charlie Griefer [mailto:charlie.grie...@gmail.com] 
Sent: September-21-09 1:50 PM
To: cf-talk
Subject: Re: Custom scopes


In other words, you're implicitly creating a structure called 'myscope' with
a key called 'var' (and then that structure gets put into the
local/variables scope anyways).

On Mon, Sep 21, 2009 at 9:46 AM, Alan Rother alan.rot...@gmail.com wrote:


 Of course.
 However... what you have really done is create a variable called

 variables.myscope.var


 =]

 --
 Alan Rother
 Adobe Certified Advanced ColdFusion MX 7 Developer
 Manager, Phoenix Cold Fusion User Group, AZCFUG.org


 



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326460
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Custom scopes

2009-09-21 Thread Cameron Childress

Rick-

It is worth noting that you are really just creating a variable of
type struct here, not a root level scope.

It's really just semantics, but it will make a difference when
communicating with other developers.  Calling it a custom scope may
confuse others.

-Cameron

On Mon, Sep 21, 2009 at 1:30 PM, Rick Sanders c...@webenergy.ca wrote:
 Thanks. Makes sense I have to create the scope before assigning a var to it!

-- 
Cameron Childress
Sumo Consulting Inc
http://www.sumoc.com
---
cell:  678.637.5072
aim:   cameroncf
email: camer...@gmail.com

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326462
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Custom scopes

2009-09-21 Thread Charlie Griefer

No, you don't have to create the 'scope' first.  Just saying:

cfset myScope.name = Charlie /

will implictly create a struct called myScope with a key of name.

but, as Cameron points out... referring to this as a custom scope will
likely lead to confusion.

Might be a good idea to back up a step or two and ask why you're looking to
do this?

On Mon, Sep 21, 2009 at 10:30 AM, Rick Sanders c...@webenergy.ca wrote:


 Thanks. Makes sense I have to create the scope before assigning a var to
 it!

 -Original Message-
 From: Charlie Griefer [mailto:charlie.grie...@gmail.com]
 Sent: September-21-09 1:50 PM
 To: cf-talk
 Subject: Re: Custom scopes


 In other words, you're implicitly creating a structure called 'myscope'
 with
 a key called 'var' (and then that structure gets put into the
 local/variables scope anyways).

 On Mon, Sep 21, 2009 at 9:46 AM, Alan Rother alan.rot...@gmail.com
 wrote:

 
  Of course.
  However... what you have really done is create a variable called
 
  variables.myscope.var
 
 
  =]
 
  --
  Alan Rother
  Adobe Certified Advanced ColdFusion MX 7 Developer
  Manager, Phoenix Cold Fusion User Group, AZCFUG.org
 
 
 



 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326463
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Custom scopes

2009-09-21 Thread Rick Sanders

I have 2 forums I want to host in CF on one server and the vars are shared.
So if I put both forums on the server, the vars will interchange between the
2 forums even if they are on different domains. So instead of going and
changing all the names of the vars in the application scope, I would just
assign the vars to a new scope and call them from there. Easy find/replace
in DW that takes a minute and fixes the issue. It's cfbb.

Rick

-Original Message-
From: Charlie Griefer [mailto:charlie.grie...@gmail.com] 
Sent: September-21-09 2:43 PM
To: cf-talk
Subject: Re: Custom scopes


No, you don't have to create the 'scope' first.  Just saying:

cfset myScope.name = Charlie /

will implictly create a struct called myScope with a key of name.

but, as Cameron points out... referring to this as a custom scope will
likely lead to confusion.

Might be a good idea to back up a step or two and ask why you're looking to
do this?

On Mon, Sep 21, 2009 at 10:30 AM, Rick Sanders c...@webenergy.ca wrote:


 Thanks. Makes sense I have to create the scope before assigning a var to
 it!

 -Original Message-
 From: Charlie Griefer [mailto:charlie.grie...@gmail.com]
 Sent: September-21-09 1:50 PM
 To: cf-talk
 Subject: Re: Custom scopes


 In other words, you're implicitly creating a structure called 'myscope'
 with
 a key called 'var' (and then that structure gets put into the
 local/variables scope anyways).

 On Mon, Sep 21, 2009 at 9:46 AM, Alan Rother alan.rot...@gmail.com
 wrote:

 
  Of course.
  However... what you have really done is create a variable called
 
  variables.myscope.var
 
 
  =]
 
  --
  Alan Rother
  Adobe Certified Advanced ColdFusion MX 7 Developer
  Manager, Phoenix Cold Fusion User Group, AZCFUG.org
 
 
 



 



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326466
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Custom scopes

2009-09-21 Thread Alan Rother

As long as you have two Application.cfcs or Aplication.cfms using different
app names the vars won't be shared between the two.
If you are using the same codebase, but two different domain names you will
need to recode the app vars so that they use different values.

something like this works well


Application.myvars[Application1].RootPath   =
e:\sites\App1\;
Application.myvars[Application2].RootPath   =
e:\sites\App2\;


=]

On Mon, Sep 21, 2009 at 11:12 AM, Rick Sanders c...@webenergy.ca wrote:


 I have 2 forums I want to host in CF on one server and the vars are shared.
 So if I put both forums on the server, the vars will interchange between
 the
 2 forums even if they are on different domains. So instead of going and
 changing all the names of the vars in the application scope, I would just
 assign the vars to a new scope and call them from there. Easy find/replace
 in DW that takes a minute and fixes the issue. It's cfbb.

 Rick

 -Original Message-
 From: Charlie Griefer [mailto:charlie.grie...@gmail.com]
 Sent: September-21-09 2:43 PM
 To: cf-talk
 Subject: Re: Custom scopes


 No, you don't have to create the 'scope' first.  Just saying:

 cfset myScope.name = Charlie /

 will implictly create a struct called myScope with a key of name.

 but, as Cameron points out... referring to this as a custom scope will
 likely lead to confusion.

 Might be a good idea to back up a step or two and ask why you're looking to
 do this?

 On Mon, Sep 21, 2009 at 10:30 AM, Rick Sanders c...@webenergy.ca wrote:

 
  Thanks. Makes sense I have to create the scope before assigning a var to
  it!
 
  -Original Message-
  From: Charlie Griefer [mailto:charlie.grie...@gmail.com]
  Sent: September-21-09 1:50 PM
  To: cf-talk
  Subject: Re: Custom scopes
 
 
  In other words, you're implicitly creating a structure called 'myscope'
  with
  a key called 'var' (and then that structure gets put into the
  local/variables scope anyways).
 
  On Mon, Sep 21, 2009 at 9:46 AM, Alan Rother alan.rot...@gmail.com
  wrote:
 
  
   Of course.
   However... what you have really done is create a variable called
  
   variables.myscope.var
  
  
   =]
  
   --
   Alan Rother
   Adobe Certified Advanced ColdFusion MX 7 Developer
   Manager, Phoenix Cold Fusion User Group, AZCFUG.org
  
  
  
 
 
 
 



 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326467
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Custom scopes

2009-09-21 Thread Ian Skinner

Alan Rother wrote:
 As long as you have two Application.cfcs or Aplication.cfms using different
 app names the vars won't be shared between the two.
 If you are using the same codebase, but two different domain names you will
 need to recode the app vars so that they use different values.

If one is using the same code base, it is possible to dynamically assign 
the application name in the Application.cfc|
cfm file based on domain names or some other factor.  The you still have 
separate variable spaces without duplicating the code base.



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326468
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Custom scopes

2009-09-21 Thread Andy Matthews

No, that's not quite true. ColdFusion allows you to implicitly create a
structure, and give it a new key in the same line:

cfset myStruct.firstname = 'andy'

Works just fine.


andy 

-Original Message-
From: Rick Sanders [mailto:c...@webenergy.ca] 
Sent: Monday, September 21, 2009 12:31 PM
To: cf-talk
Subject: RE: Custom scopes


Thanks. Makes sense I have to create the scope before assigning a var to it!

-Original Message-
From: Charlie Griefer [mailto:charlie.grie...@gmail.com]
Sent: September-21-09 1:50 PM
To: cf-talk
Subject: Re: Custom scopes


In other words, you're implicitly creating a structure called 'myscope' with
a key called 'var' (and then that structure gets put into the
local/variables scope anyways).

On Mon, Sep 21, 2009 at 9:46 AM, Alan Rother alan.rot...@gmail.com wrote:


 Of course.
 However... what you have really done is create a variable called

 variables.myscope.var


 =]

 --
 Alan Rother
 Adobe Certified Advanced ColdFusion MX 7 Developer
 Manager, Phoenix Cold Fusion User Group, AZCFUG.org


 





~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326470
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Custom scopes

2009-09-21 Thread s. isaac dealey

 
 Alan Rother wrote:
  As long as you have two Application.cfcs or Aplication.cfms using different
  app names the vars won't be shared between the two.
  If you are using the same codebase, but two different domain names you will
  need to recode the app vars so that they use different values.
 
 If one is using the same code base, it is possible to dynamically assign 
 the application name in the Application.cfc|
 cfm file based on domain names or some other factor.  The you still have 
 separate variable spaces without duplicating the code base.

That's the route I was going to suggest... Something like this should
work fairly well to separate your forums into their own applications. 

cfcomponent displayname=Application.cfc
  cfset temp = cgi.server_name /
  cfset temp = rereplace(temp,^www\.,) /
  cfset temp = listfirst(temp,.) /
  cfset this.applicationname = temp /
  
  ... 
  
/cfcomponent

-- 
s. isaac dealey  ^  new epoch
 isn't it time for a change? 
 ph: 817.385.0301

http://onTap.riaforge.org/blog



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326474
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


scopes

2009-03-25 Thread Brian Dumbledore

ok I was trying something and did this:

cfif isdefined(url.username)
cfset form = duplicate(url)
/cfif

And then I go about the rest as if the request came from a form post (I use 
form dot notation everywhere afterwards).

When I did a cfdump var=#form# it doesn't recognize the form scope, but this 
works

cfdump var=#variables.form#

But every where else in the code it works fine (recorgnizes all form dot names 
that were originally sent as url parameters)
So is cf not supposed to handle the dump 'logically'? Can someone please reason 
this behavior? 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320928
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: scopes

2009-03-25 Thread Azadi Saryev

all your form dot names are evaluated by cf as variables.form.somename
'form' is a reserved scope name in cf. it is noted in cf reference
manual that one should NOT use built-in cf scope names as variable
names. when you do, you can never be sure what you get in the end...
like in your case, cf creates a variable named 'form' in the variables
scope - it has no relation to the built-in form scope (thus you get an
empty form dump).

what you should use instead is:

cfif structkeyexists(url, username)
  cfloop collection=#url# item=key
cfset form[key] = url[key]!--- or form[key] = duplicate(url[key])
if you need a deep copy ---
  /cfloop
/cfif

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/



Brian Dumbledore wrote:
 ok I was trying something and did this:

 cfif isdefined(url.username)
 cfset form = duplicate(url)
 /cfif

 And then I go about the rest as if the request came from a form post (I use 
 form dot notation everywhere afterwards).

 When I did a cfdump var=#form# it doesn't recognize the form scope, but 
 this works

 cfdump var=#variables.form#

 But every where else in the code it works fine (recorgnizes all form dot 
 names that were originally sent as url parameters)
 So is cf not supposed to handle the dump 'logically'? Can someone please 
 reason this behavior? 
   

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320930
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: scopes

2009-03-25 Thread Aaron Rouse

Just use the StructAppend() function, a lot less code.
cfset StructAppend(FORM, URL, false) /

May or may not want that over write flag set to false, just depends on the
situation/goals.

On Wed, Mar 25, 2009 at 11:01 AM, Azadi Saryev az...@sabai-dee.com wrote:


 all your form dot names are evaluated by cf as variables.form.somename
 'form' is a reserved scope name in cf. it is noted in cf reference
 manual that one should NOT use built-in cf scope names as variable
 names. when you do, you can never be sure what you get in the end...
 like in your case, cf creates a variable named 'form' in the variables
 scope - it has no relation to the built-in form scope (thus you get an
 empty form dump).

 what you should use instead is:

 cfif structkeyexists(url, username)
  cfloop collection=#url# item=key
cfset form[key] = url[key]!--- or form[key] = duplicate(url[key])
 if you need a deep copy ---
  /cfloop
 /cfif

 Azadi Saryev
 Sabai-dee.com
 http://www.sabai-dee.com/



 Brian Dumbledore wrote:
  ok I was trying something and did this:
 
  cfif isdefined(url.username)
  cfset form = duplicate(url)
  /cfif
 
  And then I go about the rest as if the request came from a form post (I
 use form dot notation everywhere afterwards).
 
  When I did a cfdump var=#form# it doesn't recognize the form scope, but
 this works
 
  cfdump var=#variables.form#
 
  But every where else in the code it works fine (recorgnizes all form dot
 names that were originally sent as url parameters)
  So is cf not supposed to handle the dump 'logically'? Can someone please
 reason this behavior?
 

 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320932
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: scopes

2009-03-25 Thread Brian Dumbledore

Got you. So I guess in the above scenario, when I do a form dot, it resolves to 
variables dot form dot
but if there is no dot (if I am accessing the whole structure), it doesn't try 
it in the variables scope.

I did a cfoutput#structkeylist(form)#/cfoutput and it came back as blank. 

Thanks for your time 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320934
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: scopes

2009-03-25 Thread Azadi Saryev

oh yes, structAppend, of course! forgot about that one...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/



Aaron Rouse wrote:
 Just use the StructAppend() function, a lot less code.
 cfset StructAppend(FORM, URL, false) /

 May or may not want that over write flag set to false, just depends on the
 situation/goals.


   

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320936
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: scopes

2009-03-25 Thread Seb Duggan

If I ever need to do this, I just use:

cfset FORM = URL /

You don't need to duplicate the Struct, as you're not going to have  
any problems with the original URL data changing throughout the  
lifetime of the page.


Seb

On 25 Mar 2009, at 16:17, Adrian Lynch wrote:


 I'm not sure if you're saying it works or doesn't work. If it  
 doesn't, try
 FORM.putAll(URL) or StructAppend(FORM, URL) to get the URL vars into  
 the
 FORM scope.

 Adrian

 -Original Message-
 From: Brian Dumbledore [mailto:psteja2...@yahoo.com]
 Sent: 25 March 2009 16:31
 To: cf-talk
 Subject: scopes


 ok I was trying something and did this:

 cfif isdefined(url.username)
 cfset form = duplicate(url)
 /cfif

 And then I go about the rest as if the request came from a form  
 post (I
 use form dot notation everywhere afterwards).

 When I did a cfdump var=#form# it doesn't recognize the form scope,
 but this works

 cfdump var=#variables.form#

 But every where else in the code it works fine (recorgnizes all form
 dot names that were originally sent as url parameters)
 So is cf not supposed to handle the dump 'logically'? Can someone
 please reason this behavior?



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320943
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: scopes

2009-03-25 Thread Adrian Lynch

I'm not sure if you're saying it works or doesn't work. If it doesn't, try
FORM.putAll(URL) or StructAppend(FORM, URL) to get the URL vars into the
FORM scope.

Adrian

 -Original Message-
 From: Brian Dumbledore [mailto:psteja2...@yahoo.com]
 Sent: 25 March 2009 16:31
 To: cf-talk
 Subject: scopes
 
 
 ok I was trying something and did this:
 
 cfif isdefined(url.username)
 cfset form = duplicate(url)
 /cfif
 
 And then I go about the rest as if the request came from a form post (I
 use form dot notation everywhere afterwards).
 
 When I did a cfdump var=#form# it doesn't recognize the form scope,
 but this works
 
 cfdump var=#variables.form#
 
 But every where else in the code it works fine (recorgnizes all form
 dot names that were originally sent as url parameters)
 So is cf not supposed to handle the dump 'logically'? Can someone
 please reason this behavior?
 
 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320940
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: scopes

2009-03-25 Thread Brian Dumbledore

It never hurts to ask. Thank you all for your time. cfset form = url seems 
simple but I am not sure if it sets the default form structure to refer to url 
structure or it creates a variables.form wihch refers to url. 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320948
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CFCs, Scopes Thread Safety code review

2009-01-01 Thread Glyn Jackson
yes thats where query in the add to cart comes into play, from now on when they 
add an item I check to see if it is active AND active = 'on' lol

anyhow again thank for the help :) 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317310
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: CFCs, Scopes Thread Safety code review

2009-01-01 Thread s. isaac dealey
 yes thats where query in the add to cart comes into play, from now on
 when they add an item I check to see if it is active AND active =
 'on' lol
 
 anyhow again thank for the help :) 

I figured that was the case, but that still doesn't eliminate the race
condition. The cart lives for the duration of their session, which is
like 20 minutes or so. So the item that was active when they added it to
their cart could become inactive at any time after it's added and before
they check out. 

-- 
s. isaac dealey  ^  new epoch
 isn't it time for a change? 
 ph: 781.769.0723

http://onTap.riaforge.org/blog



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317320
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CFCs, Scopes Thread Safety code review

2009-01-01 Thread Glyn Jackson
I figured that was the case, but that still doesn't eliminate the race
condition. The cart lives for the duration of their session, which is
like 20 minutes or so. So the item that was active when they added it to
their cart could become inactive at any time after it's added and before
they check out. 


very true. 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317321
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CFCs, Scopes Thread Safety code review

2008-12-31 Thread Glyn Jackson
Hi again Isaac, you just hit the nail on the head, the query given is just 1 of 
hundreds in that CFC but the problem of the user deleting a category happen 
sometime back. Halloween products after the season had ended and a customer 
placed an order they should not. I put it down to a catching issue at the time. 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317287
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CFCs, Scopes Thread Safety code review

2008-12-31 Thread s. isaac dealey
 Hi again Isaac, you just hit the nail on the head, the query given is
 just 1 of hundreds in that CFC but the problem of the user deleting a
 category happen sometime back. Halloween products after the season
 had ended and a customer placed an order they should not. I put it
 down to a catching issue at the time. 

Ahh... seasonal items... yeah, that would make it more likely... but
although I would still recommend adding the var in that function, it
won't eliminate the race condition in that case. You'll still need to
check the item(s) individually when they're added to the cart and
probably again when the user reaches the checkout if you want to handle
all the possible race-condition scenarios with that. If the guy puts
something in his cart and is shopping around for a few minutes while the
item is removed from the inventory, then he'll still get to the checkout
with the item unless you do some kind of check and tell him woops, this
was removed from the inventory. 

Although personally my preference would be not to remove anything from
the cart, like, unless they actually ran out of stock and needed to give
him a store credit or a refund, once it's in the cart, I would consider
it set until he checks out -- no price changes, etc. Because he agreed
to the price when he added it to the cart. If he agreed to 8 and then he
reaches the check out and it's 10 or 12 or whatever, he's  liable to be
unhappy about that and consider it poor service. 

-- 
s. isaac dealey  ^  new epoch
 isn't it time for a change? 
 ph: 781.769.0723

http://onTap.riaforge.org/blog



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317296
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


CFCs, Scopes Thread Safety code review

2008-12-30 Thread Glyn Jackson
I am currently on a performance crusade and have been rewriting lots of my 
current projects. One of the biggest changes as a result has been the way I 
architect my applications. I have started to use the application scope to cache 
commonly used components. For example...

===
application.appObjs = structNew();
application.appObjs.securitySQLcfc = 
createObject(component,components.security);
application.appObjs.commomSQLcfc = 
createObject(component,components.common-sql); 
===

I recently posted a comment on a blog regarding this when the CF Guru himself 
Mr Sean Corfield recommend if I was going to do this, it was possible I could 
run into some thread safety issues. Now I have to be honest, I read about this 
a year or so back but never really paid attention. However it does have me 
worried a little now.  From my understanding... because I create my CFCs in the 
application scope the CFC’s are treated just like other applications vars ie. 
everyone shares it and the issue comes because this could include scopes and 
variables in CFCs not VAR-declare. The word singleton was mention, from my JAVA 
days I remember this as being an object created once but it can't be 
instantiated elsewhere in the application, well if that’s correct then that 
was my desire right?   

Ok, on the question, honestlol

A clients website gets around 5k of traffic a day and I have already cache some 
commonly used components however this was before Mr Sean Corfield reminder on 
CFCs, Scopes  Thread Safety! I have not had any reported issues with the site. 
I am being naive or lucky? 

For example, most of the components are just simple SQL statement which I only 
want as a singleton, why create the object every time? I also don’t think 
CFCs, Scopes  Thread Safety would be an issue here, is this correct or not? 
example code...

===
cffunction name=getProductMenu returntype=query hint=returns product 
menu
cfquery name=productquery  datasource=#application.appConfig.dbSource# 
username=#application.appConfig.dbUsername# 
password=#application.appConfig.dbPassword#
SELECT s.storeId, s.name as storeName, s.metaDescription as storeMeta, 
s.pos, d.depId, d.name as depName, d.metaDescription as depMeta, d.pos, c.name 
as catName, c.metaDescription as catMeta, c.catId, (SELECT COUNT(*) as proCount 
FROM products p WHERE p.catId = c.catId AND p.active != 'off') as empt
FROM stores s
LEFT JOIN departments d on s.storeId = d.storeId
LEFT JOIN categories c on d.depId = c.depId
AND (SELECT COUNT(*) as proCount FROM products p WHERE p.catId = c.catId 
AND p.active != 'off')  0
/cfquery
cfreturn productquery
/cffunction
===

The only one code that does concern me is my cart cfc, originally if it was in 
a include and I have only just added it to a components, yes its a little messy 
at the moment but it works. I have had not issues but if someone could look at 
it :) 

sorry it long
===
cffunction name=addtoCart access=public hint=adds a new item to the cart
  !--- if cart session does not exist, create it ---
  cfif not structkeyexists(session,cartItem)
cflock timeout=60 type=exclusive
  cfset session['cartItem'] = structnew()
/cflock
  /cfif
  
  !---gets option id's from product form---
  cfif structkeyexists(FORM, optVal) AND FORM['optVal'] GT 0 AND 
FORM['optVal'] NEQ  
cfset productOptionId0 = Arraynew(1)
cfset val = #form.optVal# - 1
cfloop from=0 to=#val# index=this
  cfset Vsel = form.sel0
  cfif isDefined('form.sel0')
cfset formval = Evaluate(form.sel  this)
cfset optvals = ListFirst(formval,*)
  /cfif
  cfset ArrayAppend( productOptionId0, #optvals# ) /
/cfloop
cfset optionList = ArrayToList(productOptionId0)
cfoutput #optionList#
  cfparam name=form.productOptionId default=#optionList#,
/cfoutput
  /cfif
  
  
  
  !--- if cart item does not exist, create it ---
  cfif structkeyexists(form,productid) and form['productid'] neq  and 
structkeyexists(form,qty) and form['qty'] gt 0
!--- create default node for product id ---
cfset itemNode = pCode_#form['productid']#_1
!--- if no node exists for the given product, create it. ---
cfif not structkeyexists(session['cartItem'],itemNode)
  !--- define new node as a struct ---
  cfset session['cartItem'][itemNode] = structnew()
  cfset session['cartItem'][itemNode]['aQty'] = form['qty']
  !--- grab the product info based on id ---
  cfquery name=getProd datasource=#application.appConfig.dbSource# 
username=#application.appConfig.dbUsername

Re: CFCs, Scopes Thread Safety code review

2008-12-30 Thread Matt Quackenbush
On Tue, Dec 30, 2008 at 5:36 AM, Glyn Jackson wrote:

 application.appObjs = structNew();
 application.appObjs.securitySQLcfc =
 createObject(component,components.security);
 application.appObjs.commomSQLcfc =
 createObject(component,components.common-sql);



Just to make sure it's clear, that code above, by itself, does not cache
anything.  If you are using Application.cfc, then it would need to be placed
inside of onApplicationStart() in order to be cached.  If you are using
Application.cfm, then you would need to place it inside of a check to make
sure the variables do not exist.  For example:

cfif NOT structKeyExists(application, appObjs)
 !--- create the objects here ---
/cfif



 A clients website gets around 5k of traffic a day and I have already cache
 some commonly used components however this was before Mr Sean Corfield
 reminder on CFCs, Scopes  Thread Safety! I have not had any reported issues
 with the site. I am being naive or lucky?



5k a day is very little traffic, in terms of large scale applications.
Having no issues/bugs with that amount of traffic is not, in my opinion, a
good judge of the application's safety.



 For example, most of the components are just simple SQL statement which I
 only want as a singleton, why create the object every time? I also don't
 think CFCs, Scopes  Thread Safety would be an issue here, is this correct
 or not? example code...



If the object is shared amongst the entire application, and only needed
once, then yes, create it once and cache it.  But it still has to be thread
safe.  ;-)



 cffunction name=getProductMenu returntype=query hint=returns product
 menu
 cfquery name=productquery  datasource=#application.appConfig.dbSource#
 username=#application.appConfig.dbUsername#
 password=#application.appConfig.dbPassword#
SELECT s.storeId, s.name as storeName, s.metaDescription as storeMeta,
 s.pos, d.depId, d.name as depName, d.metaDescription as depMeta, d.pos,
 c.name as catName, c.metaDescription as catMeta, c.catId, (SELECT COUNT(*)
 as proCount FROM products p WHERE p.catId = c.catId AND p.active != 'off')
 as empt
FROM stores s
LEFT JOIN departments d on s.storeId = d.storeId
LEFT JOIN categories c on d.depId = c.depId
AND (SELECT COUNT(*) as proCount FROM products p WHERE p.catId = c.catId
 AND p.active != 'off')  0
 /cfquery
 cfreturn productquery
 /cffunction



^ That is *not* thread safe.  While you'd probably get away with it since it
is not using any client-supplied variables, it still is not thread safe.
You need to var *all* variables that are not part of the object's
properties.

cffunction name=getProductMenu
 cfset var productquery =  /

 cfquery name=productquery
 !-- the query ---
 /cfquery

 cfreturn productquery /
/cffunction

^ Now we're thread safe.

Another point, not necessarily related to thread safety, but more of a best
practices thing.  You don't really want your objects directly referencing
things that are outside of them, such as your datasource information.  This
information should really be passed into the object when it is created.  For
example...

application.appObjs.securitySQLcfc =
createObject(component,components.security).init(dbSource:
application.appConfig.dbSource, dbUsername:
application.appConfig.dbUsername, dbPassword:
application.appConfig.dbPassword);

Note that we've added an init() method to the object creation, and are
passing in three arguments for our datasource information.  Now, inside of
the CFC we'll add an init() method.

cffunction name=init hint=I initialize the object returntype=any
output=false access=public
cfargument name=dbSource type=string required=true /
cfargument name=dbUsername type=string required=true /
cfargument name=dbPassword type=string required=true /

cfscript
 variables.dbSource = arguments.dbSource;
 variables.dbUsername = arguments.dbUsername;
 variables.dbPassword = arguments.dbPassword;

 return this;
 /cfscript
/cffunction

One note to make about the returntype of the init() method.  In the example
I used 'any', but in reality I would use the class type of the object.  So,
let's say that your CFC is named 'foo.cfc', I would use returntype=foo.

Now that we have passed in our datasource information, we can alter our
queries to use it rather than going outside of the object to get data.  This
is key to encapsulation.  So our productquery would now look like so:

cfquery name=productquery datasource=#variables.dbSource#
username=#variables.dbUsername# password=#variables.dbPassword#
!--- query here ---
/cfquery

You can leave off the variables. if you'd like, but it would be better to
leave it there so that you know where those are coming from when looking
back at the code later.

Now then, I would also recommend studying about using getters and setters,
sometimes referred to as accessors and mutators.  But for the sake of
simplicity and not overwhelming you all at once, I

Re: CFCs, Scopes Thread Safety code review

2008-12-30 Thread Glyn Jackson
Sorry it was not clear about how I was catching. The CFCs are indeed created 
inside the onApplicationStart function (application.cfc)

Also re traffic: it's not a large amount I would agree, but for a small 
ecommerce store it does handle £50,000 of orders per month so for them that 
traffic is very valuable and the cart and order system all written in CF must 
be working correctly.

..NET and jsp is normally my bag but over the last few years CF has been the 
love of my life (don’t tell the wife)

Thank for the examples Matt, I really do appreciate all the help I am giving. I 
am glad I was pointed in this direction and posted here. I just needed some 
examples to understand what Sean Corfield was saying and I got it. 

The encapsulation advice was excellent, I was not aware you could e.g foo as 
the return type. I understand the principles of encapsulation, inheritance, 
polymorphism etc from my JAVA 2.0 classes back many years back but was not 
aware that most of these concepts (term used loosely) could be applied in CF 
i.e object-oriented design patterns (please not on hit me, because I said the 
word OO and CF) I would really like any links to books and articles so I can 
learn more on CFCs and OO design patterns in CF and how to apply them using 
CFCs (ps all I know currently has been self-taught from blogs and Ben Forta’s 
books)
 
Anyway back to the point: if i var-declare all variables regardless, i should 
be ok, right?

again thanks Matt have been a big help



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317272
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: CFCs, Scopes Thread Safety code review

2008-12-30 Thread Matt Quackenbush
On Tue, Dec 30, 2008 at 11:46 AM, Glyn Jackson wrote:

 Also re traffic: it's not a large amount I would agree, but for a small
 ecommerce store it does handle £50,000 of orders per month so for them that
 traffic is very valuable and the cart and order system all written in CF
 must be working correctly.



I was not knocking 5k of traffic.  Most websites don't see that in an entire
lifetime.  I was just pointing out that it should not be used as a
measurement of an application's security.  :-)



 I would really like any links to books and articles so I can learn more on
 CFCs and OO design patterns in CF and how to apply them using CFCs (ps all I
 know currently has been self-taught from blogs and Ben Forta's books)



I don't know of any OO+CF books out there off the top of my head.  Most are
written to cater to other languages such as Java.  Those same principles can
(and should) be applied to CF though.



 Anyway back to the point: if i var-declare all variables regardless, i
 should be ok, right?



Any variable that is not shared between methods should be var'd, yes.


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317273
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: CFCs, Scopes Thread Safety code review

2008-12-30 Thread Jason Fisher
Glyn,

Hal Helms (http://www.halhelms.com/) offers some solid info on OO with CF and 
you can also explore Ben Nadel's journey down the OO road 
(http://www.bennadel.com/blog/).  In addition, check out ColdBox or Model-Glue 
for OO frameworks that are pure CF. 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317274
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CFCs, Scopes Thread Safety code review

2008-12-30 Thread Glyn Jackson
@ Jason: thanks for the links I will check them out. I have been learning 
ColdBox over the last few months. It was cool until I found out half way into 
my project I could not call the layout without the handler. I don't that 
defeats the point of MVC but I needed it to brake the rules just once and it 
was not versatile to do so. The reason for this was a SOAP request where the 
page including the view needed to be retuned over HTTP by a .NET application 
(and a gateway in CF). I am sure thats another post altogether lol.

@ Matt: I know what you meant in ref to the traffic and application lol. I am 
very impressed with CF, it has taken a lot of work to make the application 
accessible and to integrate with there current systems but CF and XML work 
together very well. PS have i given up on the backend for accessibility CF + 
EXT 2.0 = not accessibility!

again thanks for all your help I am sure I will be posting more here now :) 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317275
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CFCs, Scopes Thread Safety code review

2008-12-30 Thread s. isaac dealey
Someone else probably already mentioned this. The productmenu function
is not thread safe, although it's not a huge issue. Each time the
function executes it places the query result in the variables scope of
the cfc, which isn't where you want it generally speaking... However,
the danger with this particular race condition for the moment is small.
It might result in someone getting a menu that contains a category that
doesn't have any products in it, or not containing one that does. 

But also in this case, even if you elminate the race condition within
the function, the end result of the user seeing a slightly incorrect
menu would still exist because the race condition is also created again
by the nature of the web. A guy hits the page, gets the menu and then
off somewhere else the client deletes that category. But the user still
has the page open in their browser and when they click the link, bang!
They come to a page that may or may not work because the category
doesn't exist or maybe doesn't have any products in it. 

But this is the kind of race condition that a lot of applications have and
rarely becomes an issue because well, for starters the people using the
site have to do several things at the same time and while selecting a
category is common, deleting one is not. So right off the bat, you're
not likely to see the result of the race condition very often, because
someone has to delete a category or deactivate its last product first
and that rarely happens. And then even on the rare occasion on which all
these events line up just right, I'm not sure how many people will
actually report the error or the page that's not working to the store.
Often it's not so important to them and just going somewhere else is
easier. 

So yeah, in that case, the fact that you're not having problems is kind
of coincidental. 

If we're talking about best practice on the other hand, you always want
to use a cfset var queryname = 0 / before every query in your CFCs. 

-- 
s. isaac dealey  ^  new epoch
 isn't it time for a change? 
 ph: 781.769.0723

http://onTap.riaforge.org/blog



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317278
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


2 questions: ensuring a file is only included once, and scrubbing form and url scopes

2008-08-01 Thread Pete Ruckelshaus
I've got two questions.

First: Is there a way to make sure a file is only cfincluded once?  I'm
using cfinclude to include a UDF library in the onRequestStart() method of
my application.cfc, but in my debug output, that file has a file count of 7,
which has led me to realize that it's also being included when all of the
other cfc and cfm files that go into the page are being called.

Second: What method/code do you use to scrub/trim values in the FORM and URL
scopes?

Thanks

Pete


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310052
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: 2 questions: ensuring a file is only included once, and scrubbing form and url scopes

2008-08-01 Thread Dave Phillips
Pete:

1.  You could check for the existence of a variable (or function) in the
cfinclude, like this:

cfif NOT isDefined(var_name_from_include)
cfinclude template=whatever.cfm
/cfif

2.  There are some custom tags/udfs out there for this, but I haven't used
them.  I'd check CFLIB.ORG, or maybe someone else here can recommend
something specific.

Dave

-Original Message-
From: Pete Ruckelshaus [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 01, 2008 9:46 AM
To: CF-Talk
Subject: 2 questions: ensuring a file is only included once, and scrubbing
form and url scopes

I've got two questions.

First: Is there a way to make sure a file is only cfincluded once?  I'm
using cfinclude to include a UDF library in the onRequestStart() method of
my application.cfc, but in my debug output, that file has a file count of 7,
which has led me to realize that it's also being included when all of the
other cfc and cfm files that go into the page are being called.

Second: What method/code do you use to scrub/trim values in the FORM and URL
scopes?

Thanks

Pete




~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310054
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: 2 questions: ensuring a file is only included once, and scrubbing form and url scopes

2008-08-01 Thread Loathe
trim() to trim variables.


Pete Ruckelshaus wrote:
 I've got two questions.
 
 First: Is there a way to make sure a file is only cfincluded once?  I'm
 using cfinclude to include a UDF library in the onRequestStart() method of
 my application.cfc, but in my debug output, that file has a file count of 7,
 which has led me to realize that it's also being included when all of the
 other cfc and cfm files that go into the page are being called.
 
 Second: What method/code do you use to scrub/trim values in the FORM and URL
 scopes?
 
 Thanks
 
 Pete
 
 
 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310053
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: 2 questions: ensuring a file is only included once, and scrubbing form and url scopes

2008-08-01 Thread Justin Scott
 First: Is there a way to make sure a file is only
  cfincluded once?

You can set a special variable in the included file and check for it 
before including it anywhere to ensure it only gets loaded once no 
matter how many times you call it.  In the include:

cfset someSpecialVariable = 1

When you include that file:

cfif not isDefined(someSpecialVariable)
   cfinclude template=myInclude.cfm
/cfif

 Second: What method/code do you use to scrub/trim values in the
  FORM and URL scopes?

That depends on the type of data being passed in.  For general text 
fields a trim() will do the job, and you can combine that with other 
functions to ensure it won't cause a SQL truncation error.  For integer 
values I generally use:

cfset url.someID = min(abs(val(trim(url.someID))), 2147483647)

This guarantees a positive integer to prevent errors in a variety of places.


-Justin Scott


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310055
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: 2 questions: ensuring a file is only included once, and scrubbing form and url scopes

2008-08-01 Thread William Seiter
I try to use functions and CFCs for code that may need to be included more than 
once, but I can think of a quick fix if you need to mimic an 'include_once' 
process:
at the bottom of your include code create a new unique variable.  at the top of 
the include code add a cfif not isdefined('[unique variable]') around the 
entire code.

This way if the code is run once that variable now exists and won't be run 
again.

For the Trimming, I usually use trim(form.[varname]) when I need to remove 
leading and trailing spaces

William

 
--
William E. Seiter
ColdFusion Programmer / Web Developer

Free Website Trade Publication  Website Magazine
Be sure to answer all of the questions on the subscription form, small price to 
pay for the loads of excellent content this magazine offers to Web 
Professionals for FREE!!

Have you ever read a book that changed your life?
Go to: www.winninginthemargins.com
Use PassKey: GoldenGrove
You'll be glad you did.

I've got two questions.

First: Is there a way to make sure a file is only cfincluded once?  I'm
using cfinclude to include a UDF library in the onRequestStart() method of
my application.cfc, but in my debug output, that file has a file count of 7,
which has led me to realize that it's also being included when all of the
other cfc and cfm files that go into the page are being called.

Second: What method/code do you use to scrub/trim values in the FORM and URL
scopes?

Thanks

Pete 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310057
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: 2 questions: ensuring a file is only included once, and scrubbing form and url scopes

2008-08-01 Thread Yuliang Ruan
back in the days of C/C++ we used to do this with header files all the time.

inside the included file do:

cfif isdefined(include_myfile) is 0

cfset include_myfile=1

!-- do all your foos here ---

/cfif


that way you won't have to do cfif logic in the parent includer files. 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310056
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


cfthreads, scopes, cfreport and JVM memory.

2008-06-18 Thread Ian Skinner
Welcome to part three of my asynchronous thread, JVM out-of-memory 
discussion.

To recap:  we have a process that creates ~1300, seven to ten page pdf 
form letters.  This is done asynchronously using the cfthread... tag 
so that each thread can create one letter with associated database 
transactions and disappear.  There was originally a problem with the 
threads - that once opened, they never closed.  This appears to have 
been resolved yesterday by updating the ColdFusion server from 8.0.0 to 
8.0.1.

Now the issue is that if the process is allowed to run all at once, all 
the JVM memory is used up and the system starts throwing out-of-memory 
errors.  The idea I am working with, as suggested in the previous 
discussion, is to throttle the process so that there are pauses.  This 
should allow time for memory to be cleared between batches.

The trouble is that this is not happening.  Even with the pauses the 
memory does not seem to be released until the entire process runs.  My 
theory is that the root thread spawning the child cfthreads is holding 
onto the memory objects, even the ones created in the child threads, 
until it is finished.  So it can not be cleared until the main thread 
finishes.

Is this logical?  How autonomous are variables created in spawned 
threads?  Is the default to create them in a 'thread' scope that is 
dropped when the child thread is done or in the calling parent thread?  
Is this somehow controllable?  Can I declare the variables to be local 
to the thread, if so how?  Does the 'Var' command work in threads the 
same as it does in functions to make a variable local?

On a related note, the main memory hog is the cfreport... tag.  If I 
comment out this tag, the memory usage only makes a small bump when the 
test code is run.  The question is that we are using the 'filename' 
property of the cfreport... tag so there is no identified variable to 
work with here is there?  What should be happening with whatever memory 
ColdFusion used to create the PDF file described in the cfreport... 
call after it is done with it?

  !--- BUILD REPORT ---
  cfreport template=ren.cfr format=pdf overwrite=yes
filename=#vOutputFilePath# 
cfreportparam name=pFirmNo 
value=#ResultFirms[firmno][threadIndex]#
cfreportparam name=pIssueDate value=#DateFormat(pIssueDate, 
'mm/dd/yy')#
cfreportparam name=pRenewalId value=#vRenewalSeq#
  /cfreport


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:307659
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: cfthreads, scopes, cfreport and JVM memory.

2008-06-18 Thread Ian Skinner
Yes there is a thread local scope and one can use the 'Var' keyword, but 
apparently it is somewhat unnecessary.

So this just leaves me trying to control the memory used by the 
cfreport... tag.  Instead of writing directly to a file I am putting 
the cfreport... output into a variable and then attempting to write 
that file out.  This seems to be working for the memory now, the memory 
is released and cleaned up between each batch during the sleep period to 
the throttle the report generation.

But the files are not actually being written!  Should this work?

   BUILD REPORT ---
  cfreport template=ren.cfr format=pdf overwrite=yes
name=vReportLetter 
cfreportparam name=pFirmNo 
value=#ResultFirms[firmno][threadIndex]#
cfreportparam name=pIssueDate value=#DateFormat(pIssueDate, 
'mm/dd/yy')#
cfreportparam name=pRenewalId value=#vRenewalSeq#
  /cfreport
   
   cfset arrayAppend(variables.pdfFiles,vOutputFilePath)
   cfpdf action=write source=#vReportLetter# 
destination=#vOutputFilePath# overwrite=yes

Or do I just use a cffile action=write... tag.  Isn't that just for 
text files or can I write out binary output like a PDF file?

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:307668
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: cfthreads, scopes, cfreport and JVM memory.

2008-06-18 Thread Mark Kruger
Ian,

First... I would var any variables used inside the thread.  Second, you
should be able to write this file using cffile - but I'm not sure why your
cfpdf action is not working. But you want to try this code outside your
cfthread to see how it behaves - cfthread obscures error information and
makes it difficult to troubleshoot :)

-mark



Mark A. Kruger, CFG, MCSE
(402) 408-3733 ext 105
www.cfwebtools.com
www.coldfusionmuse.com
www.necfug.com

-Original Message-
From: Ian Skinner [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 18, 2008 10:45 AM
To: CF-Talk
Subject: Re: cfthreads, scopes, cfreport and JVM memory.

Yes there is a thread local scope and one can use the 'Var' keyword, but
apparently it is somewhat unnecessary.

So this just leaves me trying to control the memory used by the
cfreport... tag.  Instead of writing directly to a file I am putting the
cfreport... output into a variable and then attempting to write that file
out.  This seems to be working for the memory now, the memory is released
and cleaned up between each batch during the sleep period to the throttle
the report generation.

But the files are not actually being written!  Should this work?

   BUILD REPORT ---
  cfreport template=ren.cfr format=pdf overwrite=yes
name=vReportLetter 
cfreportparam name=pFirmNo 
value=#ResultFirms[firmno][threadIndex]#
cfreportparam name=pIssueDate value=#DateFormat(pIssueDate,
'mm/dd/yy')#
cfreportparam name=pRenewalId value=#vRenewalSeq#
  /cfreport
   
   cfset arrayAppend(variables.pdfFiles,vOutputFilePath)
   cfpdf action=write source=#vReportLetter# 
destination=#vOutputFilePath# overwrite=yes

Or do I just use a cffile action=write... tag.  Isn't that just for text
files or can I write out binary output like a PDF file?



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:307677
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: cfthreads, scopes, cfreport and JVM memory.

2008-06-18 Thread Ian Skinner
Mark Kruger wrote:
 Ian,

 First... I would var any variables used inside the thread.  Second, you
 should be able to write this file using cffile - but I'm not sure why your
 cfpdf action is not working. But you want to try this code outside your
 cfthread to see how it behaves - cfthread obscures error information and
 makes it difficult to troubleshoot :)

 -mark
   

Yeah, that finally tracked down the problem to incorrect pound signs in 
the cfpdf... tag.  The source parameter just needs that string of the 
the PDF variable not to process it as a variable.  That is one of the 
inconsistencies of CF that trips me up most often.  When to just use the 
string of the variable and when not to in tag parameters.

Now I am struggling with how threads and memory usage work together.  I 
think I may be bouncing around a bug, at least some type of unexpected 
(for me at least) behavior.  So far it seems to center around writing 
PDF content to files.  When I straightened out the cfpdf... tag, so 
that it works correctly, I am again experiencing the phenomenon where 
JVM memory usage will just climb and climb with each iteration of PDF 
generation until the master thread is finished or the memory is full and 
CF starts throwing exceptions.  The same thing happened when the 
cfreport... tag directly wrote the PDF content it generates to a file.

The whole point of this is the create ~1300 multiple page pdf form 
letters that we know will not all fit into memory at once.  How can we 
control this so that the process can be allowed to finish?




~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:307680
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: cfthreads, scopes, cfreport and JVM memory.

2008-06-18 Thread Antony Sideropoulos
Hi Ian

You say that you are throttling the process to create a pause between
batches.

Is your throttle part of the function that creates the threads? (Given that
you say that memory isn't released until this function completes, this
probably wouldn't help.)

Look at things another way - if cfthread didn't exist, you would probably be
using cfschedule to throttle the process - ie create PDFs 1 - 20, then 21 -
40, and so on.

Can you cfschedule your function (that creates all 1300 threads) in batches,
so that this function has a chance to complete (and theoretically release
the memory that it's threads consume)? Still use threads within this
function, but if you only process 20 threads at a time, this might help.

Antony


On Thu, Jun 19, 2008 at 5:04 AM, Ian Skinner [EMAIL PROTECTED] wrote:



 The whole point of this is the create ~1300 multiple page pdf form
 letters that we know will not all fit into memory at once.  How can we
 control this so that the process can be allowed to finish?




 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:307699
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Scary fun with variables scopes.

2007-10-05 Thread Ian Skinner
Give this a try if you have a moment.

Put this code in a file test.cfm.  Note: no cfapplication  tag.

cfoutputSession.test: #session.test#/cfoutput
cfif session.test EQ true
Session Variable evaluated true.
/cfif

Then call the page with this url:  http://aDomain/test.cfm?session.test=true

Is this discussed or documented somewhere?




~|
Get involved in the latest ColdFusion discussions, product
development sharing, and articles on the Adobe Labs wiki.
http://labs/adobe.com/wiki/index.php/ColdFusion_8

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290343
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Scary fun with variables scopes.

2007-10-05 Thread Rich
Ian,
ColdFusion is evaluating the line cfif session.test EQ true and is looking
through all known scopes and is finding URL['session.text'], treating it as
a variable name, which is evaluating to true.  Ben Nadel discussed this type
of non-assertive scope reference in a recent blog post
(http://www.bennadel.com/blog/957-Code-Assertively.htm).

HTH,
Rich Kroll 


~|
Download the latest ColdFusion 8 utilities including Report Builder,
plug-ins for Eclipse and Dreamweaver updates.
http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290355
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Scary fun with variables scopes.

2007-10-05 Thread Charlie Griefer
add this:

cfoutput#isSimpleValue(session.test)#/cfoutput -- YES
cfdump var=#session# -- error

which is weird because as of CFMX, creating a variable with a dot in
the name will implicitly create a struct (soo cfset foo.bar = 123
/ would create a struct named 'foo' with a key named 'bar' and equal
to 123).

I guess the fact that 'session' is a reserved word prohibits CF from
creating it as a struct so you get a simple value of session.test
equal to 'true'.

so basically the bottom line is... you're not manipulating the
session (which doesn't even exist).

On 10/5/07, Ian Skinner [EMAIL PROTECTED] wrote:
 Give this a try if you have a moment.

 Put this code in a file test.cfm.  Note: no cfapplication  tag.

 cfoutputSession.test: #session.test#/cfoutput
 cfif session.test EQ true
 Session Variable evaluated true.
 /cfif

 Then call the page with this url:  http://aDomain/test.cfm?session.test=true

 Is this discussed or documented somewhere?




 

~|
Create robust enterprise, web RIAs.
Upgrade to ColdFusion 8 and integrate with Adobe Flex
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290356
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Scary fun with variables scopes.

2007-10-05 Thread Janet MacKay
Does this work for anyone if the variable name is something other than session? 

a href=test.cfm?test.foo=bartest.bar=fooid=2Test/a


~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72catid=648

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290362
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Scary fun with variables scopes.

2007-10-05 Thread Ron Gowen
I tried it, and dumped session: test is not there, you must have created
another struct named session, I tried dumping variables it is not there?



On 10/5/07, Ian Skinner [EMAIL PROTECTED] wrote:

 Give this a try if you have a moment.

 Put this code in a file test.cfm.  Note: no cfapplication  tag.

 cfoutputSession.test: #session.test#/cfoutput
 cfif session.test EQ true
Session Variable evaluated true.
 /cfif

 Then call the page with this url:
 http://aDomain/test.cfm?session.test=true

 Is this discussed or documented somewhere?




 

~|
Enterprise web applications, build robust, secure 
scalable apps today - Try it now ColdFusion Today
ColdFusion 8 beta - Build next generation apps

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290365
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Scary fun with variables scopes.

2007-10-05 Thread Janet MacKay
I don't think its a structure.  Just a variable name with a . in it.

Nm. I see Charlie Griefer already explained that :) 

~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72catid=648

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290370
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Scary fun with variables scopes.

2007-10-05 Thread Ron Gowen
seems it creates a struct called session in the url scope: cfdump
var=#url# /

On 10/5/07, Ron Gowen [EMAIL PROTECTED] wrote:

 I tried it, and dumped session: test is not there, you must have created
 another struct named session, I tried dumping variables it is not there?



 On 10/5/07, Ian Skinner [EMAIL PROTECTED] wrote:
 
  Give this a try if you have a moment.
 
  Put this code in a file test.cfm.  Note: no cfapplication  tag.
 
  cfoutputSession.test: #session.test#/cfoutput
  cfif session.test EQ true
 Session Variable evaluated true.
  /cfif
 
  Then call the page with this url:  
  http://aDomain/test.cfm?session.test=truehttp://adomain/test.cfm?session.test=true
 
  Is this discussed or documented somewhere?
 
 
 
 
  

~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72catid=648

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290367
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Scary fun with variables scopes.

2007-10-05 Thread Janet MacKay
I tried it, and dumped session: test is not there, you must have created
another struct named session, I tried dumping variables it is not there?

Its not a structure, but you'll see it if you dump the url scope. 

~|
Get involved in the latest ColdFusion discussions, product
development sharing, and articles on the Adobe Labs wiki.
http://labs/adobe.com/wiki/index.php/ColdFusion_8

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290366
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Scary fun with variables scopes.

2007-10-05 Thread Janet MacKay
seems it creates a struct called session in the url scope: cfdump
var=#url# /

I don't think its a structure.  Just a variable name with a . in it. 

~|
ColdFusion 8 - Build next generation apps
today, with easy PDF and Ajax features - download now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290369
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Scary fun with variables scopes.

2007-10-05 Thread Claude Schneegans
 I don't think its a structure.  Just a variable name with a . in it.

But this is unconsistent with the way CF really works:
Try CFSET test.test = 0
CFDUMP var=#test#

CFDUMP shows that test is a structure with a variable  test, not a 
variable test.test

-- 
___
REUSE CODE! Use custom tags;
See http://www.contentbox.com/claude/customtags/tagstore.cfm
(Please send any spam to this address: [EMAIL PROTECTED])
Thanks.


~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290385
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Scary fun with variables scopes.

2007-10-05 Thread Janet MacKay
But this is unconsistent with the way CF really works:
Try CFSET test.test = 0
CFDUMP var=#test#

CFDUMP shows that test is a structure with a variable  test, not a 
variable test.test

But I guess that's the point. Its not a structure in this case. Dump #URL# and 
the value is not shown as a structure. Its a simple value ie test.test.



~|
Download the latest ColdFusion 8 utilities including Report Builder,
plug-ins for Eclipse and Dreamweaver updates.
http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290386
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Scary fun with variables scopes.

2007-10-05 Thread Claude Schneegans
 But I guess that's the point. Its not a structure in this case. Dump 
#URL# and the value is not shown as a structure. Its a simple value ie 
test.test.

That's not only the point, it is also an issue, since in theory, 
variable cannot have dots in their names.
So CF is actually creating an illegal variable... what a shame!


~|
ColdFusion 8 - Build next generation apps
today, with easy PDF and Ajax features - download now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290395
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Scary fun with variables scopes.

2007-10-05 Thread Rich
  I don't think its a structure.  Just a variable name with a . in it.
 
 But this is unconsistent with the way CF really works:
 Try CFSET test.test = 0
 CFDUMP var=#test#
 
 CFDUMP shows that test is a structure with a variable  test, not a
 variable test.test

The way CF really works in the example you provided is implicitly creating
a structure when you use that syntax.  In the previous example, since
session is an existing structure CF cannot create it so it treats it as a
variable session.test that it places into the URL scope.

You can test this behavior by running the code below:

cfset tester.testme = 'i am alive' / !--- creates a structure ---

cfdump var=#tester#
cfdump var=#url#

If you place these in a file (test.cfm) and browse them with the following
urls:

Test.cfm
Test.cfm?tester.test=1

You will see that the exact same phenomenon occurs; when the struct already
exists, CF cannot implicitly create it and creates a variable with the name
provided.

HTH, 

Rich Kroll


~|
Get involved in the latest ColdFusion discussions, product
development sharing, and articles on the Adobe Labs wiki.
http://labs/adobe.com/wiki/index.php/ColdFusion_8

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290399
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Scary fun with variables scopes.

2007-10-05 Thread Claude Schneegans
 CF cannot create it so it treats it as a
variable session.test that it places into the URL scope.

And this is what is inconsistent, since a variable cannot have a dot in 
its name.

-- 
___
REUSE CODE! Use custom tags;
See http://www.contentbox.com/claude/customtags/tagstore.cfm
(Please send any spam to this address: [EMAIL PROTECTED])
Thanks.


~|
Enterprise web applications, build robust, secure 
scalable apps today - Try it now ColdFusion Today
ColdFusion 8 beta - Build next generation apps

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290414
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Scary fun with variables scopes.

2007-10-05 Thread Janet MacKay
You will see that the exact same phenomenon occurs; when the struct already
exists, CF cannot implicitly create it and creates a variable with the name
provided.

It doesn't seem to matter whether a structure exists or not. 

~|
Get involved in the latest ColdFusion discussions, product
development sharing, and articles on the Adobe Labs wiki.
http://labs/adobe.com/wiki/index.php/ColdFusion_8

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290415
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Scary fun with variables scopes.

2007-10-05 Thread James Holmes
You can, of course, protect yourself from this:

cfif StructKeyExists(session, test) AND session.test EQ true
 Session Variable evaluated true.
 /cfif

On 10/5/07, Ian Skinner [EMAIL PROTECTED] wrote:
 Give this a try if you have a moment.

 Put this code in a file test.cfm.  Note: no cfapplication  tag.

 cfoutputSession.test: #session.test#/cfoutput
 cfif session.test EQ true
 Session Variable evaluated true.
 /cfif

 Then call the page with this url:  http://aDomain/test.cfm?session.test=true

 Is this discussed or documented somewhere?

-- 
mxAjax / CFAjax docs and other useful articles:
http://www.bifrost.com.au/blog/

~|
Download the latest ColdFusion 8 utilities including Report Builder,
plug-ins for Eclipse and Dreamweaver updates.
http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290420
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Speaking of Scopes (was Re: Scope Memory)

2007-05-26 Thread C. Hatton Humphrey
 Application scope only exists once per application.  Session exists once
 for each user.  You might get away with bloated memory usage in
 application, but if you are not careful what you place in session your
 problem can very quickly multiply.

On that note I have a question - I am looking into building an app
that my company will be selling to customers to use in a shared
environment.  It's starting out as a CMS but is going to include a LOT
of user controls and module support.

The idea is that each domain will have an Application name based on
the domain which will then call a shared CFC to create a memory
cached version of the site in the Application scope.  Then, as the
pages in the CMS are called the engine does not have to call out to
the database, rather it simply references the version that is cached
in the application scope.

At least, that's the way I'm thinking of doing it... what I wonder is
how the server performance will be with 100-150 sites running, each
with their own application and different things going on.  Understand,
these are what I'd call mid-traffic sites but for the moment all
brochureware.

The point of my question - would it make more sense to have the
necessary bits to connect to the database and pull the page content on
request stored in memory or just have the entire page content already
in memory after being loaded on the first page vistit when the
application reloads?

~|
Create robust enterprise, web RIAs.
Upgrade  integrate Adobe Coldfusion MX7 with Flex 2
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:279357
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


evaluation order of CF scopes

2005-10-18 Thread Duncan
I was just thumbing through my CFMX7 Developer Exam StudyGuide and there is
a section that lists the evaluation order of the scopes of CF. Something is
bugging me though - when does application. session. server. request. get
evaluated?

--
Duncan I Loxton
www.sixfive.co.uk http://www.sixfive.co.uk
[EMAIL PROTECTED]

I can only please one person per day. Today is not looking good. Tomorrow
isn't looking much better. Dilbert


~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221414
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: evaluation order of CF scopes

2005-10-18 Thread Charlie Griefer
I believe those scopes need to be explicitly ...um...scoped :)

e.g.

cfset application.foo = bar /
cfoutput#bar#/cfoutput

will result in an error, since CF hunts thru the specific scopes
(query, arguments, variables, cgi, url, form, client) and does not
encounter 'bar' in any of them.


On 10/18/05, Duncan [EMAIL PROTECTED] wrote:
 I was just thumbing through my CFMX7 Developer Exam StudyGuide and there is
 a section that lists the evaluation order of the scopes of CF. Something is
 bugging me though - when does application. session. server. request. get
 evaluated?

 --
 Duncan I Loxton
 www.sixfive.co.uk http://www.sixfive.co.uk
 [EMAIL PROTECTED]

 I can only please one person per day. Today is not looking good. Tomorrow
 isn't looking much better. Dilbert


 

~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221415
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: evaluation order of CF scopes

2005-10-18 Thread Nathan Strutz
Charlie,

You mean:

cfset application.foo = bar /
cfoutput#foo#/cfoutput

although they'll both throw the same exception.

Duncan, one of my favorite spots in the livedocs (well, it was until i
memorized it all...) is this one, dealing directly with your question:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/0911.htm

Though, I think i like the one from cfmx 6.0 better:
http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables7.htm


-nathan strutz
http://www.dopefly.com/



On 10/18/05, Charlie Griefer [EMAIL PROTECTED] wrote:
 I believe those scopes need to be explicitly ...um...scoped :)

 e.g.

 cfset application.foo = bar /
 cfoutput#bar#/cfoutput

 will result in an error, since CF hunts thru the specific scopes
 (query, arguments, variables, cgi, url, form, client) and does not
 encounter 'bar' in any of them.


 On 10/18/05, Duncan [EMAIL PROTECTED] wrote:
  I was just thumbing through my CFMX7 Developer Exam StudyGuide and there is
  a section that lists the evaluation order of the scopes of CF. Something is
  bugging me though - when does application. session. server. request. get
  evaluated?
 
  --
  Duncan I Loxton
  www.sixfive.co.uk http://www.sixfive.co.uk
  [EMAIL PROTECTED]
 
  I can only please one person per day. Today is not looking good. Tomorrow
  isn't looking much better. Dilbert
 
 
 

 

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221416
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: evaluation order of CF scopes

2005-10-18 Thread Duncan
ok so these particular scopes dont get searched through if an unamed var is
present.

Do I also understand that if you do this:

cfset foo = bar /
cfoutput#foo#/cfoutput

a) foo is actually sitting in the variables scope?
b) and that foo is only available to
- child templates included with cfinclude and
- this current template

Is this correct?

On 10/19/05, Nathan Strutz [EMAIL PROTECTED] wrote:

 Charlie,

 You mean:

 cfset application.foo = bar /
 cfoutput#foo#/cfoutput

 although they'll both throw the same exception.

 Duncan, one of my favorite spots in the livedocs (well, it was until i
 memorized it all...) is this one, dealing directly with your question:
 http://livedocs.macromedia.com/coldfusion/7/htmldocs/0911.htm

 Though, I think i like the one from cfmx 6.0 better:

 http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables7.htm


 -nathan strutz
 http://www.dopefly.com/



 On 10/18/05, Charlie Griefer [EMAIL PROTECTED] wrote:
  I believe those scopes need to be explicitly ...um...scoped :)
 
  e.g.
 
  cfset application.foo = bar /
  cfoutput#bar#/cfoutput
 
  will result in an error, since CF hunts thru the specific scopes
  (query, arguments, variables, cgi, url, form, client) and does not
  encounter 'bar' in any of them.
 
 
  On 10/18/05, Duncan [EMAIL PROTECTED] wrote:
   I was just thumbing through my CFMX7 Developer Exam StudyGuide and
 there is
   a section that lists the evaluation order of the scopes of CF.
 Something is
   bugging me though - when does application. session. server. request.
 get
   evaluated?
  
   --
   Duncan I Loxton
   www.sixfive.co.uk http://www.sixfive.co.uk http://www.sixfive.co.uk
 
   [EMAIL PROTECTED]
  
   I can only please one person per day. Today is not looking good.
 Tomorrow
   isn't looking much better. Dilbert
  
  
  
 
 

 

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221432
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: evaluation order of CF scopes

2005-10-18 Thread Aaron Rouse
Yeah, cfset foo = bar / is making a variable named foo within the
variables scope.

On 10/18/05, Duncan [EMAIL PROTECTED] wrote:

 ok so these particular scopes dont get searched through if an unamed var
 is
 present.

 Do I also understand that if you do this:

 cfset foo = bar /
 cfoutput#foo#/cfoutput

 a) foo is actually sitting in the variables scope?
 b) and that foo is only available to
 - child templates included with cfinclude and
 - this current template

 Is this correct?

 On 10/19/05, Nathan Strutz [EMAIL PROTECTED] wrote:
 
  Charlie,
 
  You mean:
 
  cfset application.foo = bar /
  cfoutput#foo#/cfoutput
 
  although they'll both throw the same exception.
 
  Duncan, one of my favorite spots in the livedocs (well, it was until i
  memorized it all...) is this one, dealing directly with your question:
  http://livedocs.macromedia.com/coldfusion/7/htmldocs/0911.htm
 
  Though, I think i like the one from cfmx 6.0 better:
 
 
 http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables7.htm
 
 
  -nathan strutz
  http://www.dopefly.com/
 
 
 
  On 10/18/05, Charlie Griefer [EMAIL PROTECTED] wrote:
   I believe those scopes need to be explicitly ...um...scoped :)
  
   e.g.
  
   cfset application.foo = bar /
   cfoutput#bar#/cfoutput
  
   will result in an error, since CF hunts thru the specific scopes
   (query, arguments, variables, cgi, url, form, client) and does not
   encounter 'bar' in any of them.
  
  
   On 10/18/05, Duncan [EMAIL PROTECTED] wrote:
I was just thumbing through my CFMX7 Developer Exam StudyGuide and
  there is
a section that lists the evaluation order of the scopes of CF.
  Something is
bugging me though - when does application. session. server. request.
  get
evaluated?
   
--
Duncan I Loxton
www.sixfive.co.uk http://www.sixfive.co.uk 
 http://www.sixfive.co.uk http://www.sixfive.co.uk
  
[EMAIL PROTECTED]
   
I can only please one person per day. Today is not looking good.
  Tomorrow
isn't looking much better. Dilbert
   
   
   
  
  
 
 

 

~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221434
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: evaluation order of CF scopes

2005-10-18 Thread Justin D. Scott
foo would also be available to custom tags and templates included using
CFMODULE in the caller scope (caller.foo).

Another scope not mentioned yet is request in which variables are
available throughout the life of a single request as request.varname
regardless if it's called from the same page, an included page, or a custom
tag/module.  Request variables must be scoped (like application/session)
IIRC.


-Justin


 -Original Message-
 From: Duncan [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, October 18, 2005 10:52 PM
 To: CF-Talk
 Subject: Re: evaluation order of CF scopes
 
 ok so these particular scopes dont get searched through if an 
 unamed var is
 present.
 
 Do I also understand that if you do this:
 
 cfset foo = bar /
 cfoutput#foo#/cfoutput
 
 a) foo is actually sitting in the variables scope?
 b) and that foo is only available to
 - child templates included with cfinclude and
 - this current template
 
 Is this correct?
 
 On 10/19/05, Nathan Strutz [EMAIL PROTECTED] wrote:
 
  Charlie,
 
  You mean:
 
  cfset application.foo = bar /
  cfoutput#foo#/cfoutput
 
  although they'll both throw the same exception.
 
  Duncan, one of my favorite spots in the livedocs (well, it 
 was until i
  memorized it all...) is this one, dealing directly with 
 your question:
  http://livedocs.macromedia.com/coldfusion/7/htmldocs/0911.htm
 
  Though, I think i like the one from cfmx 6.0 better:
 
  
 http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFus
 ion_MX_Applications_with_CFML/Variables7.htm
 
 
  -nathan strutz
  http://www.dopefly.com/
 
 
 
  On 10/18/05, Charlie Griefer [EMAIL PROTECTED] wrote:
   I believe those scopes need to be explicitly ...um...scoped :)
  
   e.g.
  
   cfset application.foo = bar /
   cfoutput#bar#/cfoutput
  
   will result in an error, since CF hunts thru the specific scopes
   (query, arguments, variables, cgi, url, form, client) and does not
   encounter 'bar' in any of them.
  
  
   On 10/18/05, Duncan [EMAIL PROTECTED] wrote:
I was just thumbing through my CFMX7 Developer Exam 
 StudyGuide and
  there is
a section that lists the evaluation order of the scopes of CF.
  Something is
bugging me though - when does application. session. 
 server. request.
  get
evaluated?
   
--
Duncan I Loxton
www.sixfive.co.uk http://www.sixfive.co.uk 
 http://www.sixfive.co.uk
  
[EMAIL PROTECTED]
   
I can only please one person per day. Today is not 
 looking good.
  Tomorrow
isn't looking much better. Dilbert
   
   
   
  
  
 
  
 
 

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221435
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: evaluation order of CF scopes

2005-10-18 Thread Aaron Rouse
I forgot to mention, I typically will just refer to anything within the
variables scope with the scope prefixed. So in your exampled I would do
cfset foo = bar /cfoutput#Variables.foo#/cfoutput I have gotten into
this happen due to years of working with other peoples code who hardly scope
much of anything and make it a little harder to debug errors when trying to
figure out where foo came in from.

On 10/18/05, Aaron Rouse [EMAIL PROTECTED] wrote:

 Yeah, cfset foo = bar / is making a variable named foo within the
 variables scope.

 On 10/18/05, Duncan  [EMAIL PROTECTED] wrote:
 
  ok so these particular scopes dont get searched through if an unamed var
  is
  present.
 
  Do I also understand that if you do this:
 
  cfset foo = bar /
  cfoutput#foo#/cfoutput
 
  a) foo is actually sitting in the variables scope?
  b) and that foo is only available to
  - child templates included with cfinclude and
  - this current template
 
  Is this correct?
 
  On 10/19/05, Nathan Strutz [EMAIL PROTECTED] wrote:
  
   Charlie,
  
   You mean:
  
   cfset application.foo = bar /
   cfoutput#foo#/cfoutput
  
   although they'll both throw the same exception.
  
   Duncan, one of my favorite spots in the livedocs (well, it was until i
 
   memorized it all...) is this one, dealing directly with your question:
   http://livedocs.macromedia.com/coldfusion/7/htmldocs/0911.htm
  
   Though, I think i like the one from cfmx 6.0 better:
  
   http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables7.htm
 
  
  
   -nathan strutz
   http://www.dopefly.com/
  
  
  
   On 10/18/05, Charlie Griefer  [EMAIL PROTECTED] wrote:
I believe those scopes need to be explicitly ...um...scoped :)
   
e.g.
   
cfset application.foo = bar /
cfoutput#bar#/cfoutput
   
will result in an error, since CF hunts thru the specific scopes
(query, arguments, variables, cgi, url, form, client) and does not
encounter 'bar' in any of them.
   
   
On 10/18/05, Duncan [EMAIL PROTECTED] wrote:
 I was just thumbing through my CFMX7 Developer Exam StudyGuide and
 
   there is
 a section that lists the evaluation order of the scopes of CF.
   Something is
 bugging me though - when does application. session. server.
  request.
   get
 evaluated?

 --
 Duncan I Loxton
 www.sixfive.co.uk http://www.sixfive.co.uk http://www.sixfive.co.uk
   http://www.sixfive.co.uk
   
 [EMAIL PROTECTED]

 I can only please one person per day. Today is not looking good.
   Tomorrow
 isn't looking much better. Dilbert



   
   
  
  
 
  

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221437
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: evaluation order of CF scopes

2005-10-18 Thread Charlie Griefer
i second Aaron, but i'd take it a step further and scope the variable
when setting it.

cfset variables.foo = bar /

while there are (rare) occassions when you actually don't want to
scope variables, they're few and far between.  a general rule of thumb
is to scope all of your variables.  including the local (variables)
scope.

On 10/18/05, Aaron Rouse [EMAIL PROTECTED] wrote:
 I forgot to mention, I typically will just refer to anything within the
 variables scope with the scope prefixed. So in your exampled I would do
 cfset foo = bar /cfoutput#Variables.foo#/cfoutput I have gotten into
 this happen due to years of working with other peoples code who hardly scope
 much of anything and make it a little harder to debug errors when trying to
 figure out where foo came in from.

 On 10/18/05, Aaron Rouse [EMAIL PROTECTED] wrote:
 
  Yeah, cfset foo = bar / is making a variable named foo within the
  variables scope.
 
  On 10/18/05, Duncan  [EMAIL PROTECTED] wrote:
  
   ok so these particular scopes dont get searched through if an unamed var
   is
   present.
  
   Do I also understand that if you do this:
  
   cfset foo = bar /
   cfoutput#foo#/cfoutput
  
   a) foo is actually sitting in the variables scope?
   b) and that foo is only available to
   - child templates included with cfinclude and
   - this current template
  
   Is this correct?
  
   On 10/19/05, Nathan Strutz [EMAIL PROTECTED] wrote:
   
Charlie,
   
You mean:
   
cfset application.foo = bar /
cfoutput#foo#/cfoutput
   
although they'll both throw the same exception.
   
Duncan, one of my favorite spots in the livedocs (well, it was until i
  
memorized it all...) is this one, dealing directly with your question:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/0911.htm
   
Though, I think i like the one from cfmx 6.0 better:
   
http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables7.htm
  
   
   
-nathan strutz
http://www.dopefly.com/
   
   
   
On 10/18/05, Charlie Griefer  [EMAIL PROTECTED] wrote:
 I believe those scopes need to be explicitly ...um...scoped :)

 e.g.

 cfset application.foo = bar /
 cfoutput#bar#/cfoutput

 will result in an error, since CF hunts thru the specific scopes
 (query, arguments, variables, cgi, url, form, client) and does not
 encounter 'bar' in any of them.


 On 10/18/05, Duncan [EMAIL PROTECTED] wrote:
  I was just thumbing through my CFMX7 Developer Exam StudyGuide and
  
there is
  a section that lists the evaluation order of the scopes of CF.
Something is
  bugging me though - when does application. session. server.
   request.
get
  evaluated?
 
  --
  Duncan I Loxton
  www.sixfive.co.uk http://www.sixfive.co.uk 
  http://www.sixfive.co.uk
http://www.sixfive.co.uk

  [EMAIL PROTECTED]
 
  I can only please one person per day. Today is not looking good.
Tomorrow
  isn't looking much better. Dilbert
 
 
 


   
   
  
  

 

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221438
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: evaluation order of CF scopes

2005-10-18 Thread Aaron Rouse
Lately I have been swaying on doing this myself. I do it for obvious reasons
within CFCs but have yet to completely make the jump on other pages. I have
been trying to focus more on naming conventions. For years I have prefixed
structures with stc, queries with qry and arrays with ary but never bothered
for just strings, lists, and so on.

On 10/18/05, Charlie Griefer [EMAIL PROTECTED] wrote:

 i second Aaron, but i'd take it a step further and scope the variable
 when setting it.

 cfset variables.foo = bar /

 while there are (rare) occassions when you actually don't want to
 scope variables, they're few and far between. a general rule of thumb
 is to scope all of your variables. including the local (variables)
 scope.




~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221439
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


SECRET CF SCOPES DISCOVERED IN AN ASTEROID

2005-03-11 Thread Steve Brownlee
In an amazing, three (1) year investigation full of intrigue, corporate
shuffling and clown beatings - five (7) new ColdFusion scopes were found
written on the inside of a Martian asteroid found in the Arctic tundra of
Wisconsin.  Lead investigator and main scientist, Patty O'Doar, released this
statement today at a press conference held outside the Center for Outer Space
Training and Cool Objects (COSTCO).

It's pretty cool.

Pretty cool, indeed.  After finding these secret scopes, the scientists used
the latest DNA testing, carbon dating and mood ring technology known to
mankind to identify, and categorize these Earth-shattering discoveries.
While these naming conventions may look vaguely familiar, like those of
subatomic quarks, their names were carefully chosen to describe their purpose
in emerging Third World countries.

ScopePurpose
-
PERA This scope contains information about the 
 server environment that is usually beyond
 what a developer can normally access.  For
 example, you can determine what the temperature
 in the room is, what type of soda the DBA
 is drinking or who farted.

TELA Ever spent hours trying to figure out where
 that elusive bug is when reviewing the code 
 of some moron who can't use a basic methodology?
 Assigning variables to this scope will allow
 you zoom right into the source of the problem. 

STETHA   Variables in this scope will provide info on
 the status of your system.  Since the hardware
 of servers is the heartbeat of any organization,
 being able to tell at a glance how everything
 is performing can be critical.

JYRA Perhaps the most amazing new scope to be discovered,
 Jyra variables, when used correctly, will prevent
 your site from ever toppling due to hacker attacks,
 service outages, or hardware failures.

COLADA   The most destructive of the new scopes. To use a
 physics analogy, it's the anti-Jyra scope. Any 
 attempted use of variables in this scope has 
 rendered the server inoperable due to catastrophic
 fragmenting of the hard drive sectors.  Any attempts
 to defragment causes irreversible failure.


Disclaimer
--
I know this belongs on any other list than CF-Talk but it's the only one I
subscribe to and since I was too lazy to go ahead and sign up for it, I
release it here and await the flames.  It's been a long week - can't you
tell?

~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:198506
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Variable Session scopes

2004-10-28 Thread Carl V
What is the best way of creating variable session scopes called from a global vars 
page without CF chucking errors..

global vars page
cfscript
 request.sessionVar = mySite; // This changes across the mini sites
 request.dbsitePrefix = test;
/cfscript

Application.cfm Page - and yes sessionmanagement is on  
cfif Not IsDefined(SESSION[request.sessionVar])

cfscript
SESSION[request.sessionVar] = StructNew();
SESSION[request.sessionVar].USERNAME = ;
SESSION[request.sessionVar].OBJECTID = ;
SESSION[request.sessionVar].USER_LOGGEDIN = false;
SESSION[request.sessionVar].Agree = False;
/cfscript
/cfif


cfif NOT SESSION[request.sessionVar].USER_LOGGEDIN
cflocation addtoken=no url=signin.cfm
/cfif

The error I get is Element USER_LOGGEDIN is undefined in a CFML structure referenced 
as part of an expression, plus other pages throughout the site which have other 
similar things

Test.cfm
cfif NOT SESSION[request.sessionVar].Agree
cflocation addtoken=no url=index.cfm
/cfif

Thanks

Carl

~|
Purchase from House of Fusion, a Macromedia Authorized Affiliate and support the CF 
community.
http://www.houseoffusion.com/banners/view.cfm?bannerid=34

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:182791
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Variable Session scopes

2004-10-28 Thread Stephen Moretti (cfmaster)
Carl V wrote:

What is the best way of creating variable session scopes called from a global vars 
page without CF chucking errors..

global vars page
cfscript
 request.sessionVar = mySite; // This changes across the mini sites
 request.dbsitePrefix = test;
/cfscript

Application.cfm Page - and yes sessionmanagement is on  
cfif Not IsDefined(SESSION[request.sessionVar])

cfscript
SESSION[request.sessionVar] = StructNew();
SESSION[request.sessionVar].USERNAME = ;
SESSION[request.sessionVar].OBJECTID = ;
SESSION[request.sessionVar].USER_LOGGEDIN = false;
SESSION[request.sessionVar].Agree = False;
/cfscript
/cfif
  

Its probably worth copying your session variable to a local variable, so 
that you don't keep hitting the session and to make it easier to access 
your variables.

request.thisSession = duplicate(session[request.sessionVar]);

This way your login references will be 
request.thisSession.Username/ObjectID/user_LoggedIn

You will need to remember to copy the thisSession variable back into 
session[request.sessionVar] at the end of the request, just in case any 
changes were made.

Hope this helps

Regards

Stephen


~|
Purchase from House of Fusion, a Macromedia Authorized Affiliate and support the CF 
community.
http://www.houseoffusion.com/banners/view.cfm?bannerid=36

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:182792
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


  1   2   3   >