使用CFC继承/扩展时暂存我的Coldfusion应用程序 [英] Staging my Coldfusion app when using CFC inheritance/extends

查看:332
本文介绍了使用CFC继承/扩展时暂存我的Coldfusion应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在webroot的子目录中有一个application.cfc:

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

/app/application.cfc

我最近在其子目录中添加了另一个application.cfc,它使用所描述的代理方法扩展了原始的application.cfc这里 http://corfield.org/blog/index.cfm /do/blog.entry/entry/Extending_Your_Root_Applicationcfc

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

subdir cfc的extends属性如下:

The extends attribute for the subdir cfc looks like this:

<cfcomponent extends="app.applicationProxy">

这一切都可以正常工作到目前为止,但这里更多的背景:我已经通过放入我的应用程序/ app调用/ appstaging旁边的目录。这工作正常,即没有冲突,因为我使用所有相对路径,我的更高级的application.cfc计算出它的dir,设置一个变量(例如application.appdir)和代码可以使用它来构造相对路径如果它需要它。

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.

这里是我的问题:现在我有新的/app/mysubdir/application.cfc,我需要的路径,扩展真的是 appstaging.applicationProxy如果这是分段目录树。 ColdFusion坚持认为extend的值是不变的。它不会让我弄清楚我在哪里,并把正确的dirname,像我一直在做其他地方。

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.

有没有办法解决这个? / p>

Is there any way to solve this?

推荐答案

如果您使用的是CF8,请在application.cfc中使用新的this.mappings结构。它看起来大致像这样。我会留给你写代码,以确定你是否在/ app或/ appstaging:

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)
.mappings [/ app] = expandPath(/ appstaging); //或任何...只是获得您的appstaging目录的完整路径

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

,当这个application.cfc在/ app下运行时,它会工作,因为它总是有。当它运行在appstaging,它会告诉coldfusion,对于这个应用程序,app指向appstaging。

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".

这篇关于使用CFC继承/扩展时暂存我的Coldfusion应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆