[coldbox 3.8.1] Wirebox Scanlocations with period in foldername

I’m trying to get wirebox to use models from an external location. I was able to get this working fine in development, but have an odd problem on production server.

The location of the folder I need to map to has periods in one of the folder names. Having these periods seems to resdult in coldbox treating the path as relative, and converts the periods to forwared slashes.

So, the folliwing in my config/Coldbox.cfc

`

conventions = {

modelsLocation = “/var/www/sites.domain.com.au/model”

};

`

gives me the following wirebox scan location

/var/www/admin.domain.com.au/var/www/sites/domain/com/au/model/

There are two problems here.

  1. The scanlocation is not absolute, it is relative to the root of the application setting the scan location.

  2. the periods in the folder name have been converted to forward slashes.

I’ve been struggling with this for days… anyone able to put me out of my misery?

Many Thanks

Jason

> The scanlocation is not absolute, it is relative to the root of the application setting the scan location.

Correct. Just like the handlers convention, views convention, or layouts convention; the model convention is the location within the web root that you will be putting models. You can add as many additional scan locations to your WireBox.cfc. The model convention is only for folders inside the webroot. Anything else needs to go in the WireBox.cfc’s scanlocations

> the periods in the folder name have been converted to forward slashes.

I don’t think your issues are just with WireBox. ColdFusion in general won’t handle that very well since periods are a special delimiter in component paths. There’s an assumption that you’ll never have periods in paths because that just won’t work.

The solution is simply to create a ColdFusion mapping in your Application.cfc that points to some place south of the “bad” folder.

this.mappings[ '\myExternalModels ] = ‘/var/www/sites.domain.com.au/model’;

Now set this in your config/WireBox.cfc

scanLocations = [ ‘\myExternalModels’ ],

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Thanks as always Brad.

I had actually setup a cfmapping:

this.mappings[ 'sharedModels' ] = '/var/www/sites.domain.com.au/model';

and had

wirebox.scanLocations =[ "sharedModels" ];

in my Coldbox.cfc, but wirebox didn’t seem to detect that. Do I need to actually have a Wirebox.cfc and declare it in that, or should the declaration in Coldbox.cfc. be sufficent?

The reason the model convention has to be in the web root is because ColdBox appends it to the path to the root of the site to manually “expand” it. Look at lines 347 and 348 of coldbox/system/web/config/ApplicationLoader.cfc in ColdBox 4:

configStruct[ “ModelsInvocationPath” ] = reReplace(fwSettingsStruct.ModelsConvention,"(/|\)",".",“all” );
configStruct[ “ModelsPath” ] = fwSettingsStruct.ApplicationPath & fwSettingsStruct.ModelsConvention;

> Do I need to actually have a Wirebox.cfc and declare it in that, or should the declaration in Coldbox.cfc. be sufficent?

You need to have a config/WireBox.cfc. Unlike other libraries like LogBox where the entire config can just be shoe-horned into config/ColdBox.cfc, the WireBox binder config is a bit special and needs to be it’s own CFC so it can inherit the DSL mapping functions from its superclass.

There is an optional “wirebox” struct in your ColdBox config, but it’s only two valid keys are “binder” and “singletonReload”.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com