An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

Scazu Powered By ColdFusion 8

October 23, 2007 ·

Today we migrated my startup's website to ColdFusion 8 (on a CrystalTech shared server). The migration went smoothly apart from someone on the same server already having a mapping for /model (with the ensuring "unable to find component or interface" error when I tried to bring the site up). Fortunately, ColdFusion 8 has per-application mappings - and CrystalTech have them enabled in the CF Administrator - so I was able to dynamically add mappings for all of my top-level directories inside Application.cfc and I was up and running:
<!--- ensure no one can usurp our webroot-relative paths --->
   <cfloop index="p" list="list,of,toplevel,directories">
      <cfset this.mappings["/" & p] = expandPath("/") & p />
We're looking forward to taking advantage of several of the new features in CF8 soon (it's been frustrating being on CF8 for localhost development but deploying to CFMX7).

Tags: coldfusion · scazu

12 responses

  • 1 Todd Rafferty // Oct 24, 2007 at 4:24 AM

    Being able to setup this.mappings and this.customTagPaths has been a huge boon for me. It has made my applications even more portable between machines than before. For ages, I've had to avoid global custom tags because of the shared host nature of our services and now, I'm able to use them with confidence (not that I have many custom tags, but I have a few).

    Welcome to CF8. :)
  • 2 Ben // Oct 24, 2007 at 6:01 AM

    That snippet you included makes me shudder! Not because of anything wrong with the snippet (rather clever, I think); but because of the fact that it would be necessary. Kind of scary that your application paths could be pulled out from under you accidentally.

    So my question is... would it be possible to prevent your app from using *any* mappings except those explicitly declared in Application.cfc? If possible, that might be easier than trying to remember to go back and update the anti-usurpation list whenever a directory is added to the application.
  • 3 Sean Corfield // Oct 24, 2007 at 6:18 AM

    @Ben, I think that would be a nice enhancement.

    My real criticism here would be aimed at CrystalTech for allowing mappings with &quot;common&quot; names. Thankfully HostMySite have learned that lesson and no longer allow mappings that could clash (they automatically prefix every mapping with your customer number!).

    You do not *need* mappings - you can put everything under your webroot on a shared host - so it's partly bad citizenship as well as ignorant hosting companies.
  • 4 Todd Rafferty // Oct 24, 2007 at 6:48 AM

    As of CF7, you didn't need mappings...? Wasn't CF7 the first that could finally get a individual '/' per site (shared or otherwise)? I remember having issues with this with previous CF verions, so... correct me if I'm wrong.
  • 5 Todd Rafferty // Oct 24, 2007 at 6:49 AM

    btw, I meant to ask, why did Scazu choose over
  • 6 Sean Corfield // Oct 24, 2007 at 7:16 AM

    @Todd, re: CFMX7 - someone could still steal your top-level directories by creating mappings. You just couldn't do anything about it, short of calling the hosting company and bitching them out!

    As for CrystalTech, the choice predates my involvement (and is certainly not a choice I would have made). We will be moving off them at some point (soon, hopefully) as I want CF8 on Linux (right now we're on Windows and I hate that).
  • 7 Anthony Webb // Mar 29, 2008 at 10:49 PM

    Along these same lines, we are deploying CF to a linux server in a remote data center.

    In the past (on windows) we have simply got into terminal services to do the CF administration right on the box itself.

    Now that we're migrating to linux I was wondering how people handle the remote administration and setup of their CF installs? Are people reaklly opening their CF adminstrator up to the outside world?
  • 8 Sean Corfield // Mar 30, 2008 at 1:12 AM

    @Anthony, there are a lot of options.

    One of the best in my opinion is to set up a virtual host in Apache so that CFIDE is only available on a specific named host and bound to an IP that is not accessible externally - and then access it over VPN or via an SSH tunnel.
  • 9 Andy Bellenie // Apr 18, 2008 at 3:25 AM

    Putting objects into application scope when using per-app-mappings raises some issues. Take this example application.cfc


    &lt;cfset = &quot;MyApp&quot;&gt;
    &lt;cfset this.mappings = structNew()&gt;
    &lt;cfset structinsert(this.mappings,&quot;/applicationpath&quot;,&quot;C:/MyAppFolder/&quot;)&gt;

    &lt;cffunction name=&quot;onApplicationStart&quot;&gt;
    &lt;cfset application.myobject = createobject(&quot;component&quot;,&quot;applicationpath.myobject&quot;).init()&gt;


    This simply will not work, Coldfusion will report that it cannot find the object specified. It doesn't work if you use OnRequestStart() either - the only way to do this is to do it OUTSIDE of the application.cfc, which isn't desirable or even possible depending on your application. Would be interested in other people's comments on this issue as I've not encountered any other mention of it online so far.
  • 10 Sean Corfield // Apr 18, 2008 at 7:58 AM

    @Andy, it must be something you're doing wrong. Your code works just fine for me and that's exactly how I load all my CFCs at application startup.
  • 11 Todd Rafferty // Apr 18, 2008 at 8:47 AM

    Wonder if Andy forgot to &amp;lt;cfreturn this&amp;gt; within the init() function? I can concur with Sean though, it works for me as well.

    There's only one instance I've seen it fail and that's because it wasn't inside any of the Application.cfc functions (onRequestStart,onSessionStart, etc). It was within the constructor zone, but that's easy enough to get around.
  • 12 Andy // Apr 21, 2008 at 3:21 AM

    My apologies, there was actually a typo in my paths. Took two senior developers a day to notice... sure you've been there :) Feel free to delete my comments and responses to keep this topic clean.