006
This commit is contained in:
+32
-27
@@ -29,11 +29,14 @@
|
||||
<cfset request.language="">
|
||||
<!--- кажется, нужно инициализировать датасорцы в псевдоконструкторе - onRequest не получается --->
|
||||
<!--- *** проверить, что есть - если есть, не создавать --->
|
||||
<!--- но так не работает --->
|
||||
<!--- не тут-то было: так не работает --->
|
||||
<!--- <cfif NOT structKeyExists(this.datasources,this.datasource)>
|
||||
<cfset this.datasources["#this.datasource#"]=getDS("#this.datasource#","ds_#this.datasource#")/>
|
||||
</cfif> --->
|
||||
|
||||
<!--- это работает с административно заданным датасорцем, хотя, казалось бы, не должно
|
||||
(без окружения фунекция вернет пустую структуру). Видимо, административный датасорц обнаруживается раньше.
|
||||
Проверять на пустоту не хочется, чтобы не плодить в псевдоконструкторе переменные --->
|
||||
<cfset this.datasources["#this.datasource#"]=getDS("#this.datasource#","ds_#this.datasource#")/>
|
||||
<!--- <cfdump var=#variables#/> --->
|
||||
|
||||
|
||||
@@ -76,7 +79,7 @@
|
||||
|
||||
<!--- global settings --->
|
||||
<cfset request.RECORDS_PER_PAGE=500/>
|
||||
<cfset request.APP_VERSION="0.00.005"/>
|
||||
<cfset request.APP_VERSION="0.00.006"/>
|
||||
<cfset request.STAND=getStand()/>
|
||||
|
||||
<!--- application constants --->
|
||||
@@ -350,33 +353,35 @@
|
||||
select 1;
|
||||
</cfquery>
|
||||
|
||||
<cfcatch type="database">
|
||||
<cfcatch type="any">
|
||||
<cfset system = createObject("java", "java.lang.System")/>
|
||||
|
||||
<cfloop list="class,connectionString,database,driver,dbdriver,host,port,type,url,username,password,bundleName,bundleVersion,connectionLimit,liveTimeout,validate" item="field"><!--- driver vs dbdriver --->
|
||||
<cfset var value=system.getEnv("#arguments.prefix#_#field#")/>
|
||||
<cfif isDefined("value") AND len(value)>
|
||||
<cfset structInsert(ds,field,value)/>
|
||||
</cfif>
|
||||
</cfloop>
|
||||
<cfif structIsEmpty(ds)>
|
||||
<cfthrow type="application" message="Datasource not configured" detail="Datasource not defined in the environment. Expected prefix is #arguments.prefix#"/>
|
||||
</cfif>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<!--- test datasource (just to get exception if invalid) --->
|
||||
<cftry>
|
||||
<cfquery name="qTestDs" datasource=#ds#>
|
||||
select 1;
|
||||
</cfquery>
|
||||
|
||||
<cfcatch type="any">
|
||||
<!--- <cfdump var=#ds#/><cfabort/> --->
|
||||
<cfrethrow/>
|
||||
<cfloop list="class,connectionString,database,driver,dbdriver,host,port,type,url,username,password,bundleName,bundleVersion,connectionLimit,liveTimeout,validate" item="field"><!--- driver vs dbdriver --->
|
||||
<cfset var value=system.getEnv("#arguments.prefix#_#field#")/>
|
||||
<cfif isDefined("value") AND len(value)>
|
||||
<cfset structInsert(ds,field,value)/>
|
||||
</cfif>
|
||||
</cfloop>
|
||||
<cfif structIsEmpty(ds)>
|
||||
<cfthrow type="application" message="Datasource not configured" detail="Datasource not defined in the environment. Expected prefix is #arguments.prefix#"/>
|
||||
</cfif>
|
||||
|
||||
<!--- test datasource (just to get exception if invalid) --->
|
||||
<cftry>
|
||||
<cfquery name="qTestDs" datasource=#ds#>
|
||||
select 1;
|
||||
</cfquery>
|
||||
|
||||
<cfcatch type="any">
|
||||
<!--- <cfdump var=#ds#/><cfabort/> --->
|
||||
<cfdump var=#arguments#/>
|
||||
<cfdump var=#ds#/>
|
||||
<cfrethrow/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
</cftry>
|
||||
<cfdump var=#ds#/>
|
||||
<cfreturn ds/>
|
||||
</cffunction>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user