title: Application.cfc extending cfc in subdirectory without access to CF admin or webroot subdirectories
body: <p>I'm on a shared linux server and I only have access to <a href="http://domain.com/~username/" rel="nofollow">http://domain.com/~username/</a> which maps to ~/public_html. </p>
  
  <p>I would like to use the Taffy framework for ColdFusion in this context. As far as I can tell, to use the framework you must have an <code>Application.cfc</code> that extends the Taffy framework component <code>taffy.core.api</code>.</p>
  
  <p><a href="https://github.com/atuttle/Taffy" rel="nofollow">https://github.com/atuttle/Taffy</a></p>
  
  <p><a href="https://github.com/atuttle/Taffy/wiki/Installing-Taffy" rel="nofollow">https://github.com/atuttle/Taffy/wiki/Installing-Taffy</a></p>
  
  <p><a href="https://github.com/atuttle/Taffy/wiki/So-you-want-to:-Create-a-dead-simple-CRUD-API" rel="nofollow">https://github.com/atuttle/Taffy/wiki/So-you-want-to:-Create-a-dead-simple-CRUD-API</a></p>
  
  <p>The only directories I have access to are not sub-directories of the web root and therefore (as I understand it) not subsets of the ColdFusion path. </p>
  
  <p>In my particular case I neither have access to CFADMIN nor are the server admins going to install a component I need to extend in a system-wide context where it is already on the path and accessible via global dot notation.</p>
  
  <p>The instructions say you should unzip the taffy folder into your web root, and if you can't do that, you should make it a subfolder of your api. The former is not a possibility for me and when I do the latter I get "<strong>Could not find the ColdFusion Component or Interface <code>taffy.core.api</code></strong>."</p>
  
  <p><strong>More Detail:</strong>
  My api is at <code>http://domain.com/~username/api/</code>, so I unzipped <code>/taffy to ~/public_html/api/</code>. If I copy the Taffy example at <code>taffy/examples/api</code> to <code>~/public_html/api</code> so that going to <code>http://domain.com/~username/api/</code> should access the example, I get "Could not find the ColdFusion Component or Interface taffy.core.api" even if have <code>taffy/core/api.cfc</code> beneath that directory (<code>~/public_html/api</code>).</p>
  
  <p>On this server I have successfully made cfc's that extend a cfc in another directory using <code>&lt;cfset THIS.mappings["/subdir"]= getDirectoryFromPath(getCurrentTemplatePath()) &amp; "subdir/"&gt;</code> and <code>&lt;cfobject name="parentObj" component="subdir.parent"&gt;</code>.</p>
  
  <p>I have also successfully made an Application.cfc that extends a cfc <em>in the same directory</em>.</p>
  
  <p>I just haven't successfully made an Application.cfc that can extend a cfc in another directory, even if it's a subdirectory.</p>
  
  <p>I did try to use grep &amp; related tools to strip every reference of "taffy.core" out of Taffy's source code so I could just dump all the taffy cfc's into my root directory along with Application.cfc so I could extend api.cfc, but I got <em>different</em> errors and didn't pursue that hacky solution any further. </p>
  
  <p><code>&lt;cfdump var=#expandPath('/mapping')# /&gt;</code> outputs <code>/var/www/html/mapping</code>. </p>
  
  <pre><code>uname@domain $&gt;ls -la /var/www/html
  drwxr-xr-x  3 root   root 4096 Sep 16 00:34 .
  drwxr-xr-x  7 root   root 4096 May 28  2012 ..
  lrwxrwxrwx  1 root   root   19 Sep 16 00:34 cfide -&gt; /var/www/html/CFIDE
  drwxrwxr-x 10 apache root 4096 Sep 16 00:32 CFIDE
  </code></pre>
  
  <p><code>~/public_html/api/resources/successesCollection.cfc</code>:</p>
  
  <pre><code>&lt;cfcomponent extends="taffy.core.resource" taffy_uri="/successes"&gt;
      &lt;cffunction name="get" access="public" output="false"&gt;
          &lt;cfreturn representationOf('success').withStatus(200) /&gt;
      &lt;/cffunction&gt;
  &lt;/cfcomponent&gt;
  </code></pre>
  
  <p><code>~/public_html/api/Application.cfc</code>:</p>
  
  <pre><code>&lt;cfcomponent extends="taffy.core.api"&gt;
  
  &lt;!--- doesn't work
  &lt;cfset THIS.mappings["/taffy"]= getDirectoryFromPath(getCurrentTemplatePath()) &amp; "taffy/"&gt;
  &lt;cfset THIS.mappings["/core"]= getDirectoryFromPath(getCurrentTemplatePath()) &amp; "taffy/core/"&gt;
  ---&gt;
  
          &lt;cfscript&gt;
                  this.name = hash(getCurrentTemplatePath());
  
                  // do your onApplicationStart stuff here
                  function applicationStartEvent(){}
  
                  // do your onRequestStart stuff here
                  function requestStartEvent(){}
  
                  // this function is called after the request has been parsed and all request details are known
                  function onTaffyRequest(verb, cfc, requestArguments, mimeExt){
                          // this would be a good place for you to check API key validity and other non-resource-specific validation
                          return true;
                  }
  
                  // called when taffy is initializing or when a reload is requested
                  function configureTaffy(){
                          setDebugKey("debug");
                          setReloadKey("reload");
                          setReloadPassword("true");
  
                          // Usage of this function is entirely optional. You may omit it if you want to use the default representation class.
                          // Change this to a custom class to change the default for the entire API instead of overriding for every individual response.
                          setDefaultRepresentationClass("taffy.core.genericRepresentation");
                  }
          &lt;/cfscript&gt;
  &lt;/cfcomponent&gt;
  </code></pre>
  
  <p><strong>Output of <code>http://domain.com/~uname/api/index.cfm/successes/</code>: <code>Could not find the ColdFusion Component or Interface taffy.core.api.</code></strong></p>
  
  <p>Adding this to my <code>Application.cfc</code> doesn't fix the issue: </p>
  
  <pre><code>&lt;cfcomponent extends="taffy.core.api"&gt;
          &lt;cfscript&gt;
                  this.name = hash(getCurrentTemplatePath());
                  this.mappings = StructNew();
                  this.mappings['/taffy'] =
                  expandPath('./taffy');
  </code></pre>
  
  <p>In addition, adding the following to <code>~/public_html/api/Application.cfc</code> doesn't fix the issue either: </p>
  
  <pre><code>&lt;cfset this.mappings["/taffy"] =
  expandPath(getDirectoryFromPath(getCurrentTemplatePath()) &amp; "taffy")&gt;
  </code></pre>
  
  <p>Check out the following sequence of commands and let me know if I've overlooked something. I'm still left with "Could not find the ColdFusion Component or Interface taffy.core.api" upon browsing to "http://domain/~uname/api".</p>
  
  <pre><code>[uname@domain ~]$ cd ~/public_html
  
  [uname@domain ~/public_html]$ rm -rf api
  
  [uname@domain ~/public_html/api]$ wget -O taffy.zip https://github.com/atuttle/Taffy/zipball/master
  
  [uname@domain ~/public_html/api]$ unzip taffy.zip
  
  [uname@domain ~/public_html/api]$ mv atuttle-Taffy-35df54e/ taffy
  
  [uname@domain ~/public_html/api]$ mv taffy/examples/api .
  
  [uname@domain ~/public_html/api]$ mv taffy api/
  
  [uname@domain ~/public_html/api]$ tree -d ~/public_html/api/
  ~/public_html/api/
  |-- resources
  `-- taffy
      |-- bonus
      |-- core
      |-- examples
      |   |-- ParentApplication
      |   |   |-- config
      |   |   |-- mixin
   ... etc
  
  [uname@domain ~/public_html/api]$ ls -la ~/public_html/api/
  total 8
  drwxr-xr-x  4 uname ugroup 1024 Dec  9 11:00 .
  drwxr-xr-x 10 uname web     1024 Dec  9 10:57 ..
  -rw-r--r--  1 uname ugroup 1188 Dec  9 11:00 Application.cfc
  -rw-r--r--  1 uname ugroup  172 Sep 20 13:04 .htaccess
  -rw-r--r--  1 uname ugroup  218 Sep 20 13:04 index.cfm
  drwxr-xr-x  2 uname ugroup 1024 Sep 20 13:04 resources
  drwxr-xr-x  8 uname ugroup 1024 Sep 20 13:04 taffy
  
  [uname@domain ~/public_html/api]$ ls -la ~/public_html/api/taffy/
  total 15
  drwxr-xr-x  8 uname ugroup 1024 Sep 20 13:04 .
  drwxr-xr-x  4 uname ugroup 1024 Dec  9 11:00 ..
  drwxr-xr-x  2 uname ugroup   96 Sep 20 13:04 bonus
  -rw-r--r--  1 uname ugroup 4096 Sep 20 13:04 build.xml
  drwxr-xr-x  2 uname ugroup 1024 Sep 20 13:04 core
  drwxr-xr-x 15 uname ugroup 1024 Dec  9 10:57 examples
  -rw-r--r--  1 uname ugroup   99 Sep 20 13:04 .gitignore
  drwxr-xr-x  2 uname ugroup   96 Sep 20 13:04 lib
  -rw-r--r--  1 uname ugroup 1356 Sep 20 13:04 LICENSE.TXT
  -rw-r--r--  1 uname ugroup 2490 Sep 20 13:04 ReadMe.md
  drwxr-xr-x  3 uname ugroup   96 Sep 20 13:04 snippets
  drwxr-xr-x  5 uname ugroup 1024 Sep 20 13:04 tests
  
  [uname@domain ~/public_html/api]$ ls -la ~/public_html/api/taffy/core/
  total 72
  drwxr-xr-x 2 uname ugroup  1024 Sep 20 13:04 .
  drwxr-xr-x 8 uname ugroup  1024 Sep 20 13:04 ..
  -rw-r--r-- 1 uname ugroup 42382 Sep 20 13:04 api.cfc
  -rw-r--r-- 1 uname ugroup  4574 Sep 20 13:04 baseRepresentation.cfc
  -rw-r--r-- 1 uname ugroup  2572 Sep 20 13:04 dashboard.cfm
  -rw-r--r-- 1 uname ugroup  1756 Sep 20 13:04 dashboard.css
  -rw-r--r-- 1 uname ugroup  4538 Sep 20 13:04 docs.cfm
  -rw-r--r-- 1 uname ugroup  3030 Sep 20 13:04 factory.cfc
  -rw-r--r-- 1 uname ugroup   179 Sep 20 13:04 genericRepresentation.cfc
  -rw-r--r-- 1 uname ugroup  3516 Sep 20 13:04 mocker.cfm
  -rw-r--r-- 1 uname ugroup   389 Sep 20 13:04 nativeJsonRepresentation.cfc
  -rw-r--r-- 1 uname ugroup  3765 Sep 20 13:04 resource.cfc
  </code></pre>