006
This commit is contained in:
+28
-23
@@ -29,11 +29,14 @@
|
|||||||
<cfset request.language="">
|
<cfset request.language="">
|
||||||
<!--- кажется, нужно инициализировать датасорцы в псевдоконструкторе - onRequest не получается --->
|
<!--- кажется, нужно инициализировать датасорцы в псевдоконструкторе - onRequest не получается --->
|
||||||
<!--- *** проверить, что есть - если есть, не создавать --->
|
<!--- *** проверить, что есть - если есть, не создавать --->
|
||||||
<!--- но так не работает --->
|
<!--- не тут-то было: так не работает --->
|
||||||
<!--- <cfif NOT structKeyExists(this.datasources,this.datasource)>
|
<!--- <cfif NOT structKeyExists(this.datasources,this.datasource)>
|
||||||
<cfset this.datasources["#this.datasource#"]=getDS("#this.datasource#","ds_#this.datasource#")/>
|
|
||||||
</cfif> --->
|
</cfif> --->
|
||||||
|
|
||||||
|
<!--- это работает с административно заданным датасорцем, хотя, казалось бы, не должно
|
||||||
|
(без окружения фунекция вернет пустую структуру). Видимо, административный датасорц обнаруживается раньше.
|
||||||
|
Проверять на пустоту не хочется, чтобы не плодить в псевдоконструкторе переменные --->
|
||||||
|
<cfset this.datasources["#this.datasource#"]=getDS("#this.datasource#","ds_#this.datasource#")/>
|
||||||
<!--- <cfdump var=#variables#/> --->
|
<!--- <cfdump var=#variables#/> --->
|
||||||
|
|
||||||
|
|
||||||
@@ -76,7 +79,7 @@
|
|||||||
|
|
||||||
<!--- global settings --->
|
<!--- global settings --->
|
||||||
<cfset request.RECORDS_PER_PAGE=500/>
|
<cfset request.RECORDS_PER_PAGE=500/>
|
||||||
<cfset request.APP_VERSION="0.00.005"/>
|
<cfset request.APP_VERSION="0.00.006"/>
|
||||||
<cfset request.STAND=getStand()/>
|
<cfset request.STAND=getStand()/>
|
||||||
|
|
||||||
<!--- application constants --->
|
<!--- application constants --->
|
||||||
@@ -350,33 +353,35 @@
|
|||||||
select 1;
|
select 1;
|
||||||
</cfquery>
|
</cfquery>
|
||||||
|
|
||||||
<cfcatch type="database">
|
<cfcatch type="any">
|
||||||
<cfset system = createObject("java", "java.lang.System")/>
|
<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 --->
|
<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#")/>
|
<cfset var value=system.getEnv("#arguments.prefix#_#field#")/>
|
||||||
<cfif isDefined("value") AND len(value)>
|
<cfif isDefined("value") AND len(value)>
|
||||||
<cfset structInsert(ds,field,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>
|
</cfif>
|
||||||
</cfcatch>
|
</cfloop>
|
||||||
</cftry>
|
<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) --->
|
<!--- test datasource (just to get exception if invalid) --->
|
||||||
<cftry>
|
<cftry>
|
||||||
<cfquery name="qTestDs" datasource=#ds#>
|
<cfquery name="qTestDs" datasource=#ds#>
|
||||||
select 1;
|
select 1;
|
||||||
</cfquery>
|
</cfquery>
|
||||||
|
|
||||||
<cfcatch type="any">
|
<cfcatch type="any">
|
||||||
<!--- <cfdump var=#ds#/><cfabort/> --->
|
<!--- <cfdump var=#ds#/><cfabort/> --->
|
||||||
<cfrethrow/>
|
<cfdump var=#arguments#/>
|
||||||
|
<cfdump var=#ds#/>
|
||||||
|
<cfrethrow/>
|
||||||
|
</cfcatch>
|
||||||
|
</cftry>
|
||||||
</cfcatch>
|
</cfcatch>
|
||||||
</cftry>
|
</cftry>
|
||||||
|
<cfdump var=#ds#/>
|
||||||
<cfreturn ds/>
|
<cfreturn ds/>
|
||||||
</cffunction>
|
</cffunction>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user