Thursday, May 24, 2012    
Home My Books Blog ColdFusion About Me Back    

Calendar
<< Nov 2003 >>
S M T W T F S
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            

Search

Categories
 • Acrobat (5) [RSS]
 • Adobe (117) [RSS]
 • AdobeMAX06 (45) [RSS]
 • AdobeMAX07 (59) [RSS]
 • AdobeMAX08 (66) [RSS]
 • AdobeMAX09 (39) [RSS]
 • AdobeMAX10 (34) [RSS]
 • AdobeMAX11 (28) [RSS]
 • AdobeMAX13 (1) [RSS]
 • AIR (299) [RSS]
 • Appearances (217) [RSS]
 • Books (86) [RSS]
 • CFEclipse (15) [RSS]
 • Cloud (1) [RSS]
 • ColdFusion (1483) [RSS]
 • ColdFusion Builder (23) [RSS]
 • Data Services (43) [RSS]
 • Fish Tank (5) [RSS]
 • Flash (368) [RSS]
 • Flex (565) [RSS]
 • Home Automation (5) [RSS]
 • HTML5 (36) [RSS]
 • JavaScript (3) [RSS]
 • Jobs (133) [RSS]
 • jQuery (15) [RSS]
 • JRun (14) [RSS]
 • Labs (63) [RSS]
 • LiveCycle (37) [RSS]
 • MAX (285) [RSS]
 • Mobile (257) [RSS]
 • PhoneGap (17) [RSS]
 • Regular Expressions (19) [RSS]
 • RIA (21) [RSS]
 • SQL (45) [RSS]
 • Stuff (554) [RSS]
 • Tips (CF Studio) (80) [RSS]
 • Tips (CF) (795) [RSS]
 • Tips (Dreamweaver) (91) [RSS]
 • Tips (Flex Builder) (2) [RSS]
 • Using CF (167) [RSS]

Other BLOGs
 • Charlie Arehart
 • Lee Brimelow
 • Ray Camden
 • Christophe Coenraets
 • Sean Corfield
 • Mihai Corlan
 • Cornel Creanga
 • Mark Doherty
 • John Dowdell
 • Danny Dura
 • Enrique Duvos
 • Steven Erat
 • Kevin Hoyt
 • Serge Jespers
 • Adam Lehman
 • Duane Nickull
 • Miti Pricope
 • Andrew Shorten
 • Ryan Stewart
 • James Ward
 • Greg Wilson
 • Full As A Goog

RSS Feeds
 • Feed
 • Subscribe

Join my mailing list and find out about new books and other topics of interest.

Thoughts, ideas, tips, musings, and pontifications (not necessarily in that order) by Ben Forta ...
NOTE: This is my personal blog, and the opinions and statements voiced here are my own.

Viewing By Day : November 2, 2003 / Main
November 2, 2003

How to Process Retrieved CFML?

Honestly, I have never needed to do this myself, but apparently many ColdFusion users have, and several have asked me for advice in the past few days. So ...

If you were to store CFML source code in a database so that it may be retrieved via a simple database query, what would be the best way to execute that code? You could, of course, write the code to a temporary file and then it, but that's a hack at best. It also may be possible to parse the text so as to evaluate() any expressions, but that won't work well with tags.

Whether this is a good practice or not is debatable and a separate discussion. For now, has anyone discovered a creative way to do this? If so, please share.

Comments
The only solution would be saving the content to a *.cfm file.

Although this is a possible solution, people which are looking for this kind of solutions should better take a look at their application, and the way it is build up.
# Posted By Micha Schopman | 11/3/03 11:31 AM
Actually, Micha, you can save CF code to _any_ file name and cfinclude it. It will be processed. If you were to go this route, I'd specifically use a non-CFM name and use a file outside the web root.
# Posted By Raymond Camden | 11/3/03 12:24 PM
Of course, one of the problems with going from the database to the file system and then executing it is that you get the first time compile hit (even tho' that's not such a big deal in 6.1) so it's not a very performant way to deal with the problem.

I'm with Micha on this - folks should take a look at their application and rethink their solution.
# Posted By seancorfield | 11/3/03 3:31 PM
An alternative to the automatic database processing, what about saving the files before-hand and include them programatically. In your web-based site admin, assuming you have one, on save, update the cfml file as well as the DB record. Then to be doube-sure, schedule a job to query the database every day (or hour) and update your files, as some people may update the cf code without checking in to the site.
# Posted By Nathan Strutz | 11/3/03 4:16 PM
I'm with Nathan, what would be the need to store the source code in the database? Without more feedback in that area, I'd suggest cffile writing .dbm (just to be different than normal) files and use cffile read to display for altering.

Perhaps use another solution for indexing and searching aside from a database?
# Posted By Calvin | 11/4/03 4:36 AM
I have posted many threads on the forum about this exact same functionality. I don't think it is always a matter of re-thinking the application, I built an app that needed to send emails where the email bodies were stored in a database- but the email bodies needed to be customized with the results of a query. Since once you dynamically put the email body on the page- CF will not process it again to fill in the includes. So sadly, I'm left with useing CFSAVECONTENT and then an include to get the bodies to process. I would gladly "re-think" my app if there were a better way to do this but I don't think there is.
# Posted By scoob | 11/6/03 9:18 PM
I have this problem as well. I have the body of an email stored in the db, to make it editable by an admin user. So I have

Dear #UserFirstName#

bla,bla,bla

Users knows not to mess with anything in # signs, but when I put this in the cfmail tag from the the db it does'nt work, just sends out the raw cf code

Any suggestions ?

Dharmesh
dharmesh42@hotmail.com
# Posted By Dharmesh | 11/7/03 7:34 AM
cfevaluate?
# Posted By anon | 11/13/03 11:40 AM
- Chunks of the code could reside in the database and be written out to file only when they changed. This way, repetitive use wouldn't include the regeneration and compilation cycle each time the page was browsed. Because the information is in a database, it doesn't have to be parsed back out of a text file when a minor change is needed. The information is already in the database, ready for a minor modification that replaces the existing code pages.
- Regarding WHY one would want to do this, consider a content management solution where the customer can 'build' his own mini-site by picking from several pleasing frame arrangements and selecting one of your modules (such as a catalog interface, a calendar, a text area for a message to patrons) to use in each frame. The customer supplies content for some of these modules, editing text and uploading images through forms provided by the Web host (you!). The site description dialogue can store the customer's input in a database and use it to generate (or regenerate) the site when the description is complete.
- Tupperware provides this kind of functionality to its consultants (although not with ColdFusion). See http://my.tupperware.com/AnnMarieLadner [shameless plug] for an example. To be fair, I should point out that an outside agency keeps her content fresh, proving that even niches have niches.
- Consider that there are MANY small firms that could benefit from having their own useful Web presence but can't afford to pay technical folks to keep them up to date. Further, Yahoo is reportedly getting out of this business. You could help your community and probably break even (or better) by providing this kind of service. =Marty=
# Posted By R Martin Ladner | 11/15/03 10:44 PM
I was able to get the email example to work using the evaluate and de functions.

<cfquery name=myQuery ... >
select bodyText from table
</cfquery>

<cfmail ... >
#evaluate(de(myQuery.bodyText))#
</cfmail>
# Posted By Tim | 11/18/03 3:28 PM

  © Copyright 1997-2009 Ben Forta, All Rights Reserved