I would normally post this sort of thing up on StackOverflow, but i'm not sure 
it really fits there.

So I've started messing around with (3rd party) webhooks and had a bright idea 
of using remote functions to intercept the hook.  Sure enough i wrote my 
function and started firing browser requests at it and dumping whatever came at 
it.

I was pretty pleased with myself.. then i tried getting serious.


we have a setup at work that looks kinda like this.

C:\webroot\
    C:\webroot\_objects\
    C:\webroot\site1\
    C:\webroot\site2\
    etc

Now "C:\webroot\_objects\" contains all of our objects we use along with 
Application.cfc.  C:\webroot\site1\ are our various sites containing 
"application.cfc" [small "a"].  

application.cfc tells Application.cfc which objects the sites use, and 
Application.cfc goes about loading them via .cfm files.

doing things like: 

local.stArgs    = {};
local.stArgs.sDSN = application.stSiteVars.stDSN.sShop;
local.stArgs.oCFML = application.stObj.oCFML;
local.stArgs.oFormat = application.oFormat;     
local.stArgs.sJournalCode = application.sSiteCode;
local.stArgs.oShopDAO = application.stObj.oShopDAO;
local.oShopifyOrderBusiness = 
createObject("component","_objects._core._shopify.shopifyOrderBusiness").init(argumentCollection=local.stArgs);
        
application.stObj.stShopify.oShopifyOrderBusiness = local.oShopifyOrderBusiness;

local.stArgs.oShopifyOrderBusiness = 
application.stObj.stShopify.oShopifyOrderBusiness;
        
local.oShopifyWebHookBusiness = 
createObject("component","_objects._core._shopify.shopifyWebhookBusiness").init(argumentCollection=local.stArgs);
        
application.stObj.stShopify.oShopifyWebHookBusiness = 
local.oShopifyWebHookBusiness;

As you can see, "oShopifyWebHookBusiness" takes "oShopifyOrderBusiness" as an 
argument, and within the init function of "oShopifyWebHookBusiness" it places 
oShopifyOrderBusiness into the variables scope 
("variables.oShopifyOrderBusiness = arguments.oShopifyOrderBusiness").

I guess you can see where this is leading (well if my reading is correct, if 
not you're probably lost).... When you call a remote function, it instantiates 
the object each time, meaning the init never gets called and the variables 
scope does not contain a reference to "oShopifyOrderBusiness", meaning I can't 
easily pass off anything from the remote function to another function within 
"oShopifyOrderBusiness".  

To get around this, i've had to fall back to passing webhooks to a cfm, which 
then allows me to do what i originally wanted to do, due to it already being 
instantiated with the various items in the variables scope.

Has our setup screwed us, or have i read the situation wrong and I'm missing 
something.  

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:357485
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to