Staging my Coldfusion app when using CFC inheritance/extends

瘦欲@ 提交于 2020-01-06 04:51:32

问题


I have an application.cfc in a subdir of my webroot:

/app/application.cfc

I recently added another application.cfc in a subdir of that and it extends the original application.cfc using the proxy method described here http://corfield.org/blog/index.cfm/do/blog.entry/entry/Extending_Your_Root_Applicationcfc :

/app/mysubdir/application.cfc
/app/applicationproxy.cfc

The extends attribute for the subdir cfc looks like this:

<cfcomponent extends="app.applicationProxy">

This all works fine so far but here's more background: I have been staging my app by putting it in a directory next to /app called /appstaging. This works fine, i.e. there are no conflicts, because I use all relative paths, and my higher-level application.cfc figures out which dir it's in, sets a variable (e.g. application.appdir) and code can use that to construct relative paths if it needs it.

Here's my problem: now that I have that new /app/mysubdir/application.cfc, I need the path for the extends to really be "appstaging.applicationProxy" if this is the staging dir tree. ColdFusion insists though that the value for "extends" be constant. It won't let me figure out where I am and put in the proper dirname like I've been doing everywhere else.

Is there any way to solve this?


回答1:


If you're on CF8, use the new this.mappings structure in your application.cfc. It'd look roughly like this. I'll leave it up to you to write the code to figure out whether you're in /app or /appstaging:

if(inAppStaging) this.mappings["/app"] = expandPath("/appstaging");//or whatever... just get a full path to your appstaging directory

This way, when this application.cfc is run under /app, it'll work just as it always has. When it's run in appstaging, it'll tell coldfusion that for this application, "app" points to "appstaging".



来源:https://stackoverflow.com/questions/1677312/staging-my-coldfusion-app-when-using-cfc-inheritance-extends

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!