0

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?

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
DaveBurns
  • 2,036
  • 2
  • 27
  • 37
  • Use multiple instances of CF? – Henry Nov 04 '09 at 23:22
  • I'm on a shared hosting service so no can do. Someone a while ago suggested I get a 2nd hosting account but I'd like to avoid that if possible. – DaveBurns Nov 04 '09 at 23:39
  • How about... Use a built tool like ANT to fill in the path in extends? – Henry Nov 04 '09 at 23:45
  • I have come to separate sub-domains for staging applications in similar situation. – Sergey Galashyn Nov 05 '09 at 10:46
  • Forgot to mention: I'm on CF7 still. An upgrade is planned but no timeline set yet. The subdomain idea is interesting. I'll look into that. – DaveBurns Nov 05 '09 at 12:54
  • Henry - I don't use Ant yet. My current deployment method ties in with my staging dir arrangement: after the customer and I vet the /appstaging code, I "deploy" it by renaming /app to /app.bak then /appstaging to /app. I then reinit the app to make sure the OnApplicationStart is re-run. I'd like to keep this simplicity rather than move to Ant if possible. – DaveBurns Nov 06 '09 at 06:15

1 Answers1

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

marc esher
  • 4,871
  • 3
  • 36
  • 51
  • hmmmm. on second thought, reading it more closely, this probably won't work. drats. – marc esher Nov 05 '09 at 00:30
  • I was going to suggest using GetCurrentTemplatePath() and started working up an example when I saw what I bet you see, Marc... the problem is that Application.cfc doesn't have access to the mapping for "/app" until it's done creating it, so it can't extend that. You should be able to do it with a global mapping, though. – Adam Tuttle Nov 05 '09 at 12:17
  • I'm on CF7 still (unfortunately). An upgrade is planned but no timeline set yet. I use GetCurrentTemplatePath already to determine if I'm in app or appstaging so I like your idea since it is right in line with how I already work things. – DaveBurns Nov 05 '09 at 12:57