Re: Setting client variable datasource via config.xml

2011-08-14 Thread Brian Kotek

Yes, I'm sure it works. I've updated this to script syntax but don't have
that code handy, but here is the tag-based way I do it:

In the pseudoconstructor:

!--- Initialize all environment-specific variables, including DSN, ORM
settings, and configuration settings. ---
cfset initializeEnvironment() /


OnApplicationStart:

cffunction name=onApplicationStart returnType=boolean output=false
 cfset initializeEnvironment() /
cfset ORMReload() /
 cfreturn true
/cffunction


The method:

cffunction name=initializeEnvironment access=private output=false
returntype=any
 cfset var local = StructNew() /
 cfif IsDefined( 'application' ) EQ false OR ( IsDefined( 'application' )
AND not StructKeyExists( application, 'globalProperties' ) )
 !--- Get the global properties for this environment, based on the server
name ---
 cfset local.globalProperties = StructNew() /
cfset local.globalProperties = CreateObject(
'component','com.util.Environment'
).init(xmlFile='/config/environment/environment.xml').getDefaultEnvironment()
/
 cfif IsDefined( 'application' ) AND not StructKeyExists( application,
'globalProperties' )
 cfset application.globalProperties = local.globalProperties /
/cfif
 cfelse
cfset local.globalProperties = application.globalProperties /
 /cfif

cfset this.ormenabled = true /
 cfset this.datasource = local.globalProperties.datasource /
cfset this.ormsettings = local.globalProperties.ormSettings /
/cffunction


This way, on first load the XML is actually read twice, once in the
pseudoconstructor (to set the initial values), and then once in
OnApplicationStart (where it is cached into the application scope). All
subsequent requests populate the instance variables in Application.cfc (like
datasource and ormsettings) via the cached settings data.



On Fri, Aug 12, 2011 at 12:57 PM, Russ Michaels r...@michaels.me.uk wrote:


 Hmm, are you sure that would work, as you still surely need to initialise
 the application first before checking if anything exist as
 OnApplicationstart will run first.
 So if your application settings are coming form the XML file, you need them
 even before the Application initialises and checks for the existence of the
 application vars.

 On Fri, Aug 12, 2011 at 5:19 PM, Brook Davies cft...@logiforms.com
 wrote:

 
  Good Solution, thanks!
 
  -Original Message-
  From: Brian Kotek [mailto:brian...@gmail.com]
  Sent: August-11-11 9:47 PM
  To: cf-talk
  Subject: Re: Setting client variable datasource via config.xml
 
 
  Right, set up a function that you call to get the variables, and have it
  read the XML the first time, and on any subsequent calls just use the XML
  already loaded rather than load it again.
 
 
  On Fri, Aug 12, 2011 at 12:17 AM, Matt Quackenbush
  quackfu...@gmail.comwrote:
 
  
   No, you cannot do
  
   cfset this.clientStorage = application.gs.clientVarDataSource /
  
   You might get away with that after the application has already been
   init'd, but even then it would be a false positive and would stop
   working as soon as the application timed out or the application server
   was restarted.
However,
   you *can* do something like so:
  
   this.clientStorage = getClientStorageDatasource();
  
   function getClientStorageDatasource()
   {
   // read your xml file and extract the variable
   return theDatasource;
   }
  
   HTH
  
  
   On Thu, Aug 11, 2011 at 10:57 PM, Brook Davies cft...@logiforms.com
   wrote:
  
   
But can you set this.clientstorage that way? Because It seems
setting
   that
property within onRequestStart() does not work. In my requestStart
method
   I
call another method which sets a client var. If I set the
this.client[(storage|Management|etc] in the onRequestStart, I get an
   error
that the client scope is not enabled when I try to set a client var
in a method called from there.
   
Sorry to be using client variables Nathan :(
   
Brook
   
-Original Message-
From: Russ Michaels [mailto:r...@michaels.me.uk]
Sent: August-11-11 5:45 PM
To: cf-talk
Subject: Re: Setting client variable datasource via config.xml
   
   
I used to have this issue as well, you obviously cannot read read
app
   vars
that do not exist yet and you cannot create them until the
application scope is initialised.
The way I got round this is to have 2 XML files.
One that contains the init variables that need to exist before the
application scope is initialised, and I load these into request
scope onapplicationstart. Once this is done, I then load the global
config into the application scope.
   
   
   
On Thu, Aug 11, 2011 at 11:06 PM, Brook Davies
cft...@logiforms.com
wrote:
   

 I'm trying to set all my apps properties via a config file to make
 deployment between dev, production servers easy. Problem is the
 application vars that are read via onApplicationStart() are not
 available within the opening part

Re: Setting client variable datasource via config.xml

2011-08-12 Thread Jochem van Dieten

On Fri, Aug 12, 2011 at 12:06 AM, Brook Davies wrote:
 I'm trying to set all my apps properties via a config file to make
 deployment between dev, production servers easy. Problem is the application
 vars that are read via onApplicationStart() are not available within the
 opening part of the application.cfc and when I try to set these properties
 inside onRequestStart() they do not work. Should I be able to set these in
 onRequestsStart()?

We have moved those parts of the configuration required for code
outside the methods in Application.cfc to the onServerStart() method
of Server.cfc. That only works because we deploy one application per
instance though.

Jochem

-- 
Jochem van Dieten
http://jochem.vandieten.net/

~|
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:346716
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: Setting client variable datasource via config.xml

2011-08-12 Thread Brook Davies

Good Solution, thanks!

-Original Message-
From: Brian Kotek [mailto:brian...@gmail.com] 
Sent: August-11-11 9:47 PM
To: cf-talk
Subject: Re: Setting client variable datasource via config.xml


Right, set up a function that you call to get the variables, and have it
read the XML the first time, and on any subsequent calls just use the XML
already loaded rather than load it again.


On Fri, Aug 12, 2011 at 12:17 AM, Matt Quackenbush
quackfu...@gmail.comwrote:


 No, you cannot do

 cfset this.clientStorage = application.gs.clientVarDataSource /

 You might get away with that after the application has already been 
 init'd, but even then it would be a false positive and would stop 
 working as soon as the application timed out or the application server 
 was restarted.
  However,
 you *can* do something like so:

 this.clientStorage = getClientStorageDatasource();

 function getClientStorageDatasource()
 {
 // read your xml file and extract the variable
 return theDatasource;
 }

 HTH


 On Thu, Aug 11, 2011 at 10:57 PM, Brook Davies cft...@logiforms.com
 wrote:

 
  But can you set this.clientstorage that way? Because It seems 
  setting
 that
  property within onRequestStart() does not work. In my requestStart 
  method
 I
  call another method which sets a client var. If I set the 
  this.client[(storage|Management|etc] in the onRequestStart, I get an
 error
  that the client scope is not enabled when I try to set a client var 
  in a method called from there.
 
  Sorry to be using client variables Nathan :(
 
  Brook
 
  -Original Message-
  From: Russ Michaels [mailto:r...@michaels.me.uk]
  Sent: August-11-11 5:45 PM
  To: cf-talk
  Subject: Re: Setting client variable datasource via config.xml
 
 
  I used to have this issue as well, you obviously cannot read read 
  app
 vars
  that do not exist yet and you cannot create them until the 
  application scope is initialised.
  The way I got round this is to have 2 XML files.
  One that contains the init variables that need to exist before the 
  application scope is initialised, and I load these into request 
  scope onapplicationstart. Once this is done, I then load the global 
  config into the application scope.
 
 
 
  On Thu, Aug 11, 2011 at 11:06 PM, Brook Davies 
  cft...@logiforms.com
  wrote:
 
  
   I'm trying to set all my apps properties via a config file to make 
   deployment between dev, production servers easy. Problem is the 
   application vars that are read via onApplicationStart() are not 
   available within the opening part of the application.cfc and when 
   I try to set these properties inside onRequestStart() they do not
work.
   Should I be able to set these in onRequestsStart()?
  
  
  
   cfcomponent output=false extends=coldfireApplication
  
  
  
  cfset this.clientManagement= true
  
  cfset this.setClientCookies= true
  
  cfset this.setDomainCookies= false
  
  cfset this.clientStorage   =
 application.gs.clientVarDataSource
  
  
  
  
  
  
  
 
 
 
 

 



~|
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:346723
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Setting client variable datasource via config.xml

2011-08-12 Thread Russ Michaels

Hmm, are you sure that would work, as you still surely need to initialise
the application first before checking if anything exist as
OnApplicationstart will run first.
So if your application settings are coming form the XML file, you need them
even before the Application initialises and checks for the existence of the
application vars.

On Fri, Aug 12, 2011 at 5:19 PM, Brook Davies cft...@logiforms.com wrote:


 Good Solution, thanks!

 -Original Message-
 From: Brian Kotek [mailto:brian...@gmail.com]
 Sent: August-11-11 9:47 PM
 To: cf-talk
 Subject: Re: Setting client variable datasource via config.xml


 Right, set up a function that you call to get the variables, and have it
 read the XML the first time, and on any subsequent calls just use the XML
 already loaded rather than load it again.


 On Fri, Aug 12, 2011 at 12:17 AM, Matt Quackenbush
 quackfu...@gmail.comwrote:

 
  No, you cannot do
 
  cfset this.clientStorage = application.gs.clientVarDataSource /
 
  You might get away with that after the application has already been
  init'd, but even then it would be a false positive and would stop
  working as soon as the application timed out or the application server
  was restarted.
   However,
  you *can* do something like so:
 
  this.clientStorage = getClientStorageDatasource();
 
  function getClientStorageDatasource()
  {
  // read your xml file and extract the variable
  return theDatasource;
  }
 
  HTH
 
 
  On Thu, Aug 11, 2011 at 10:57 PM, Brook Davies cft...@logiforms.com
  wrote:
 
  
   But can you set this.clientstorage that way? Because It seems
   setting
  that
   property within onRequestStart() does not work. In my requestStart
   method
  I
   call another method which sets a client var. If I set the
   this.client[(storage|Management|etc] in the onRequestStart, I get an
  error
   that the client scope is not enabled when I try to set a client var
   in a method called from there.
  
   Sorry to be using client variables Nathan :(
  
   Brook
  
   -Original Message-
   From: Russ Michaels [mailto:r...@michaels.me.uk]
   Sent: August-11-11 5:45 PM
   To: cf-talk
   Subject: Re: Setting client variable datasource via config.xml
  
  
   I used to have this issue as well, you obviously cannot read read
   app
  vars
   that do not exist yet and you cannot create them until the
   application scope is initialised.
   The way I got round this is to have 2 XML files.
   One that contains the init variables that need to exist before the
   application scope is initialised, and I load these into request
   scope onapplicationstart. Once this is done, I then load the global
   config into the application scope.
  
  
  
   On Thu, Aug 11, 2011 at 11:06 PM, Brook Davies
   cft...@logiforms.com
   wrote:
  
   
I'm trying to set all my apps properties via a config file to make
deployment between dev, production servers easy. Problem is the
application vars that are read via onApplicationStart() are not
available within the opening part of the application.cfc and when
I try to set these properties inside onRequestStart() they do not
 work.
Should I be able to set these in onRequestsStart()?
   
   
   
cfcomponent output=false extends=coldfireApplication
   
   
   
   cfset this.clientManagement= true
   
   cfset this.setClientCookies= true
   
   cfset this.setDomainCookies= false
   
   cfset this.clientStorage   =
  application.gs.clientVarDataSource
   
   
   
   
   
   
   
  
  
  
  
 
 



 

~|
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:346725
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Setting client variable datasource via config.xml

2011-08-11 Thread Brook Davies

I'm trying to set all my apps properties via a config file to make
deployment between dev, production servers easy. Problem is the application
vars that are read via onApplicationStart() are not available within the
opening part of the application.cfc and when I try to set these properties
inside onRequestStart() they do not work. Should I be able to set these in
onRequestsStart()?

 

cfcomponent output=false extends=coldfireApplication



cfset this.clientManagement= true

cfset this.setClientCookies= true

cfset this.setDomainCookies= false

cfset this.clientStorage   = application.gs.clientVarDataSource

 

..

 

 




~|
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:346710
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Setting client variable datasource via config.xml

2011-08-11 Thread Brook Davies

I'm trying to set all my apps properties via a config file to make
deployment between dev, production servers easy. Problem is the application
vars that are read via onApplicationStart() are not available within the
opening part of the application.cfc and when I try to set these properties
inside onRequestStart() they do not work. Should I be able to set these in
onRequestsStart()?

 

cfcomponent output=false extends=coldfireApplication



cfset this.clientManagement= true

cfset this.setClientCookies= true

cfset this.setDomainCookies= false

cfset this.clientStorage   = application.gs.clientVarDataSource

 




~|
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:346711
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Setting client variable datasource via config.xml

2011-08-11 Thread Russ Michaels

I used to have this issue as well, you obviously cannot read read app vars
that do not exist yet and you cannot create them until the application scope
is initialised.
The way I got round this is to have 2 XML files.
One that contains the init variables that need to exist before the
application scope is initialised, and I load these into request scope
onapplicationstart. Once this is done, I then load the global config into
the application scope.



On Thu, Aug 11, 2011 at 11:06 PM, Brook Davies cft...@logiforms.com wrote:


 I'm trying to set all my apps properties via a config file to make
 deployment between dev, production servers easy. Problem is the application
 vars that are read via onApplicationStart() are not available within the
 opening part of the application.cfc and when I try to set these properties
 inside onRequestStart() they do not work. Should I be able to set these in
 onRequestsStart()?



 cfcomponent output=false extends=coldfireApplication



cfset this.clientManagement= true

cfset this.setClientCookies= true

cfset this.setDomainCookies= false

cfset this.clientStorage   = application.gs.clientVarDataSource






 

~|
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:346712
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: Setting client variable datasource via config.xml

2011-08-11 Thread Brook Davies

But can you set this.clientstorage that way? Because It seems setting that
property within onRequestStart() does not work. In my requestStart method I
call another method which sets a client var. If I set the
this.client[(storage|Management|etc] in the onRequestStart, I get an error
that the client scope is not enabled when I try to set a client var in a
method called from there. 

Sorry to be using client variables Nathan :(

Brook

-Original Message-
From: Russ Michaels [mailto:r...@michaels.me.uk] 
Sent: August-11-11 5:45 PM
To: cf-talk
Subject: Re: Setting client variable datasource via config.xml


I used to have this issue as well, you obviously cannot read read app vars
that do not exist yet and you cannot create them until the application scope
is initialised.
The way I got round this is to have 2 XML files.
One that contains the init variables that need to exist before the
application scope is initialised, and I load these into request scope
onapplicationstart. Once this is done, I then load the global config into
the application scope.



On Thu, Aug 11, 2011 at 11:06 PM, Brook Davies cft...@logiforms.com wrote:


 I'm trying to set all my apps properties via a config file to make 
 deployment between dev, production servers easy. Problem is the 
 application vars that are read via onApplicationStart() are not 
 available within the opening part of the application.cfc and when I 
 try to set these properties inside onRequestStart() they do not work. 
 Should I be able to set these in onRequestsStart()?



 cfcomponent output=false extends=coldfireApplication



cfset this.clientManagement= true

cfset this.setClientCookies= true

cfset this.setDomainCookies= false

cfset this.clientStorage   = application.gs.clientVarDataSource






 



~|
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:346713
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Setting client variable datasource via config.xml

2011-08-11 Thread Matt Quackenbush

No, you cannot do

cfset this.clientStorage = application.gs.clientVarDataSource /

You might get away with that after the application has already been init'd,
but even then it would be a false positive and would stop working as soon as
the application timed out or the application server was restarted.  However,
you *can* do something like so:

this.clientStorage = getClientStorageDatasource();

function getClientStorageDatasource()
{
 // read your xml file and extract the variable
 return theDatasource;
}

HTH


On Thu, Aug 11, 2011 at 10:57 PM, Brook Davies cft...@logiforms.com wrote:


 But can you set this.clientstorage that way? Because It seems setting that
 property within onRequestStart() does not work. In my requestStart method I
 call another method which sets a client var. If I set the
 this.client[(storage|Management|etc] in the onRequestStart, I get an error
 that the client scope is not enabled when I try to set a client var in a
 method called from there.

 Sorry to be using client variables Nathan :(

 Brook

 -Original Message-
 From: Russ Michaels [mailto:r...@michaels.me.uk]
 Sent: August-11-11 5:45 PM
 To: cf-talk
 Subject: Re: Setting client variable datasource via config.xml


 I used to have this issue as well, you obviously cannot read read app vars
 that do not exist yet and you cannot create them until the application
 scope
 is initialised.
 The way I got round this is to have 2 XML files.
 One that contains the init variables that need to exist before the
 application scope is initialised, and I load these into request scope
 onapplicationstart. Once this is done, I then load the global config into
 the application scope.



 On Thu, Aug 11, 2011 at 11:06 PM, Brook Davies cft...@logiforms.com
 wrote:

 
  I'm trying to set all my apps properties via a config file to make
  deployment between dev, production servers easy. Problem is the
  application vars that are read via onApplicationStart() are not
  available within the opening part of the application.cfc and when I
  try to set these properties inside onRequestStart() they do not work.
  Should I be able to set these in onRequestsStart()?
 
 
 
  cfcomponent output=false extends=coldfireApplication
 
 
 
 cfset this.clientManagement= true
 
 cfset this.setClientCookies= true
 
 cfset this.setDomainCookies= false
 
 cfset this.clientStorage   = application.gs.clientVarDataSource
 
 
 
 
 
 
 



 

~|
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:346714
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Setting client variable datasource via config.xml

2011-08-11 Thread Brian Kotek

Right, set up a function that you call to get the variables, and have it
read the XML the first time, and on any subsequent calls just use the XML
already loaded rather than load it again.


On Fri, Aug 12, 2011 at 12:17 AM, Matt Quackenbush quackfu...@gmail.comwrote:


 No, you cannot do

 cfset this.clientStorage = application.gs.clientVarDataSource /

 You might get away with that after the application has already been init'd,
 but even then it would be a false positive and would stop working as soon
 as
 the application timed out or the application server was restarted.
  However,
 you *can* do something like so:

 this.clientStorage = getClientStorageDatasource();

 function getClientStorageDatasource()
 {
 // read your xml file and extract the variable
 return theDatasource;
 }

 HTH


 On Thu, Aug 11, 2011 at 10:57 PM, Brook Davies cft...@logiforms.com
 wrote:

 
  But can you set this.clientstorage that way? Because It seems setting
 that
  property within onRequestStart() does not work. In my requestStart method
 I
  call another method which sets a client var. If I set the
  this.client[(storage|Management|etc] in the onRequestStart, I get an
 error
  that the client scope is not enabled when I try to set a client var in a
  method called from there.
 
  Sorry to be using client variables Nathan :(
 
  Brook
 
  -Original Message-
  From: Russ Michaels [mailto:r...@michaels.me.uk]
  Sent: August-11-11 5:45 PM
  To: cf-talk
  Subject: Re: Setting client variable datasource via config.xml
 
 
  I used to have this issue as well, you obviously cannot read read app
 vars
  that do not exist yet and you cannot create them until the application
  scope
  is initialised.
  The way I got round this is to have 2 XML files.
  One that contains the init variables that need to exist before the
  application scope is initialised, and I load these into request scope
  onapplicationstart. Once this is done, I then load the global config into
  the application scope.
 
 
 
  On Thu, Aug 11, 2011 at 11:06 PM, Brook Davies cft...@logiforms.com
  wrote:
 
  
   I'm trying to set all my apps properties via a config file to make
   deployment between dev, production servers easy. Problem is the
   application vars that are read via onApplicationStart() are not
   available within the opening part of the application.cfc and when I
   try to set these properties inside onRequestStart() they do not work.
   Should I be able to set these in onRequestsStart()?
  
  
  
   cfcomponent output=false extends=coldfireApplication
  
  
  
  cfset this.clientManagement= true
  
  cfset this.setClientCookies= true
  
  cfset this.setDomainCookies= false
  
  cfset this.clientStorage   =
 application.gs.clientVarDataSource
  
  
  
  
  
  
  
 
 
 
 

 

~|
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:346715
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm