I have been playing around with my tweeked methodology of Fusebox and 
cfObjects, and recently built a very rough prototype assertion checker 
that uses the existing fusedocs for the information.  

The way it works is:
1. Reads the file as text
2. Retrieves only the <in> elements
3. Loops through the elements checking to see if the required variables 
are there, non-required have a default value and setting the values.
4. After this it includes the file requested.

I have pasted the code below here for the checker and some code for the 
test.

------- Interface Node code (ide.cfm) ----------

<cfsilent>
<cfif Not ParameterExists(attributes.action)>
        <cfset attributes.action ="test">
</cfif>

<cffile action="READ" 
         
file="#GetDirectoryFromPath(GetBaseTemplatePath())##attributes.action#.cfm"

                variable="Assertion">
                
<cfset testIt = Trim(Mid(Assertion, 
FindNoCase('<in>',Assertion)+Len('<in>'), 
FindNoCase('</in>',Assertion)-(FindNoCase('<in>',Assertion)+Len('<in>'))))>

<cfset r = 0>
<cfset n = 0>
</cfsilent>
<cfloop condition="Len(testIt)">
        <!--- <string name="attributes.Userpass" required="No" default="nopass" 
/> --->
        <cfset test = Left(testIt, FindNoCase(' />', testIt)+3)>
        <cfset type = Mid(test,2,FindNoCase(' ',test)-2)>
        <cfset nme = Mid(test, (FindNoCase('name="', test) + 6), Len(test))>
        <cfset nme = Trim(Left(nme, FindNoCase('"', nme)-1))>
        <cfif FindNoCase('required="Yes"',test)>
                <cfset r = r + 1>
                <cfif Not Evaluate("ParameterExists(" & nme & ")")>
                        <cfabort showerror="Required #nme# was not present!">
                </cfif>
                <cfset dft="">
        <cfelse>
                <cfset n = n + 1>
                <cfif Not FindNoCase('default="', test)>
                        <cfabort showerror="#nme# is listed as a non-required 
variable, but 
has no default value!">
                </cfif>
                <cfset dft = Mid(test, (FindNoCase('default="', test) + 
Len('default="')), Len(test))>
                <cfset dft = Trim(Left(dft, FindNoCase('"', dft)-1))>
                <cfparam name="#nme#" default="#dft#" type="#type#">
        </cfif>
        <cfset testIt = Trim(ReplaceNoCase(testIt, test, ""))>
</cfloop>

<cfinclude template="#attributes.action#.cfm">

------- Test file ----------

<!---
<fusedoc fuse="test.cfm">
        <responsibilities>
                I display a welcome screen with basic information to a teacher when 
they log in to the system.  I am there home screen and default screen 
for all actions to be performed.
        </responsibilities>     
        <io>
                <in>
                        <string name="URL.Username" required="Yes" default="" />
                        <string name="attributes.Userpass" required="No" 
default="nopass" />
                </in>
        </io>
</fusedoc>
--->

<cfoutput>
<strong>User name:</strong> #URL.Username#<br>
<strong>Password:</strong> #attributes.Userpass#<br>
</cfoutput>
<br>
This is a test, I repeat this is only a test.


-------- URL used to test ---------
http://localhost/ide.cfm?Username=this

==^================================================================
This email was sent to: [email protected]

EASY UNSUBSCRIBE click here: http://topica.com/u/?bUrFMa.bV0Kx9
Or send an email to: [EMAIL PROTECTED]

T O P I C A -- Register now to manage your mail!
http://www.topica.com/partner/tag02/register
==^================================================================

Reply via email to