Very quickly... I've talked about this twice:
- "So there won't be support for OSX 10.9 "Mavericks" on ColdFusion 10"
- "Adobe backtracks on no-support for ColdFusion 10 on OSX 10.9"
quick test: if you cfinclude an html file with #cfml does the #cfml get processed? https://t.co/itCTMYSkSCBefore checking the Gist or progressing... answer the question for yourself.
— mikehenke (@mikehenke) October 30, 2013
Future of the web - vertical | Areas | ||||
---|---|---|---|---|---|
Mobile | Enterprise Mobility | ||||
Responsive Multi Screen Content | |||||
Modernized Platform | High Performance Runtime | ||||
Modular Nimble Engine | |||||
Enterprise Class Package Manager | |||||
Language Revamp | |||||
Horizontals | |||||
Peformance | Security | HTML5 |
Stack Overflow is basically the Stanford Prison Experiment playing out on the internet.Classic.
defer()
to CFLib and Code Review yesterday. And Adam Tuttle quickly spotted a shortfall in my implementation. And whilst addressing that spotted two more bugs, which I have now fixed.you're not doing a thread join in this code anywhere, which means that if the deferred job takes longer than the rest of the request to run, it will not be able to affect the response.
[...]
For your function to be useful, either the result of the job function can't be something that's needed to create the response, or you'll need to add a way to expose a join reference for the created thread.
public struct function defer(required function job, function onSuccess, function onFailure, function onError, function onTerminate){
var threadId = "deferredThread_#createUuid()#";
local[threadId] = "";
try {
cfthread.status = "Running";
thread name=threadId action="run" attributecollection=arguments {
try {
successData.result = job();
cfthread.status = "Completed";
if (structKeyExists(attributes, "onSuccess")){
onSuccess(successData);
}
} catch (any e){
cfthread.status = "Failed";
if (structKeyExists(attributes, "onFailure")){
onFailure(e);
}else{
rethrow;
}
}
}
} catch (any e){
cfthread.status = "Errored";
if (structKeyExists(arguments, "onError")){
onError(e);
}else{
rethrow;
}
}
return {
getStatus = function(){
return cfthread.status;
},
getThreadId = function(){
return threadId;
},
terminate = function(){
if (cfthread.status == "Running"){
thread name=threadId action="terminate";
cfthread.status = "Terminated";
if (isDefined("onTerminate")){
onTerminate();
}
}
}
};
}
[...]I propose adding closure callback support to the following functions/operations so they can be processed natively in the background (non-blocking) and then call back when done.The bits I omitted ([...]) are simply for abbreviation, and preserve the gist of his suggestion. This is a reasonable idea in general, but - as I go on to say in the thread - I don't think the suggested approach is very good for a coupla reasons. It's not bad, but it just seems a bit "embryonic" to me. But this is fine, this is what discussion forums are for.
FileRead
FileWrite
[...]
etc
Basically any operation that can block a network or local resource. Imagine doing this:
fileRead( file, function(contents){
process file here in the background once it is read.
});
[...]
listEach()
on CFLib
@RobGcf there isn't specific loop construct for looping over lists in CFScript. #ColdFusionScott more helpfully pointed out that converting the list to an array and looping that is a good approach. I agree.
— Adam Cameron (@dacCfml) October 16, 2013
public array function listEach(required string list, required function callback, string delimiters=","){
var arr = listToArray(list, delimiters);
var arrLen = arrayLen(arr);
var result = [];
for (var index=1; index <= arrLen; index++){
arrayAppend(result, callBack(argumentCollection=arguments, index=index, element=arr[index], length=arrLen));
}
return result;
}
arraySetEach()
UDF, passing all the passed-in args to the callback, plus the position the iterating index is at, and the value, and in this case the length of the list being processed.numbers = "tahi|rua|toru|wha";
function _ucase(){
return ucase(element);
}
upperCasedNumbers = listEach(numbers, _ucase, "|");
writeOutput(serializeJson(upperCasedNumbers));
["TAHI","RUA","TORU","WHA"]
<ol>
:function toOL(){
if (index == 1){
writeOutput("<ol>");
}
writeOutput('<li id="index_#index#">#element#</li>');
if (index == length){
writeOutput("</ol>");
}
}
listEach(numbers, toOL, "|");
<ol>
<li id="index_1">tahi</li>
<li id="index_2">rua</li>
<li id="index_3">toru</li>
<li id="index_4">wha</li>
</ol>
toOL()
UDF would probably be better done in tags, given we're outputting mark-up:<cffunction name="toOL">
<cfif index EQ 1>
<ul>
</cfif>
<cfoutput><li id="index_#index#">#element#</li></cfoutput>
<cfif index EQ length>
</ul>
</cfif>
</cffunction>
function listEach(list, callback, delimiters){
var arr = false;
var arrLen = false;
var result = [];
var index = 0;
if (!structKeyExists(arguments, "delimiters")){
delimiters = ",";
}
arr = listToArray(list, delimiters);
arrLen = arrayLen(arr);
for (index=1; index <= arrLen; index++){
arrayAppend(result, callBack(argumentCollection=arguments, index=index, element=arr[index], length=arrLen));
}
return result;
}
VAR
s at the top, and scope my arguments specifically in some places in the calling code:function toOL(){
if (arguments.index == 1){
writeOutput("<ol>");
}
writeOutput('<li id="index_#arguments.index#">#arguments.element#</li>');
if (arguments.index == arguments.length){
writeOutput("</ol>");
}
}
serialize()
rainbow = ["Whero","Karaka","Kowhai","Kakariki","Kikorangi","Tawatawa","Mawhero"];
serialisedViaFunction = serialize(rainbow);
deserialised = evaluate(serialisedViaFunction);
writeDump([rainbow,serialisedViaFunction,deserialised]);
sameStructs = [];
arraySet(sameStructs, 1, 5, {});
sameStructs[3].foo = "bar";
writeDump(sameStructs);
ColdFusion now supports a CFC with an onServerStart method that runs only when the server starts. The onServerStart method takes no parameters, and is the only function in the CFC. The function is useful for application-independent tasks, such as instantiating the applications, configuring logging, or setting up the scheduler.Apparently Railo does not offer this functionality. But also have never had anyone notice this.
By default, ColdFusion looks for the onServerStart method in cf_webroot/Server.cfc.
thread
idea...
<cfthread>
(or, indeed, just thread
) again...request.findMe = "here";
function f(string request){
// get the request scope
writeDump(var=[request]); // blocker
writeDump(var=[structGet("request")]); // blocker
}
f("blocker");
I tend to be a bit "forthright": I think CF is a good product, but I won't blindly defend it in all circumstances, and I have been quite critical of ColdFusion and Adobe at times. This will come out occasionally here: I make no apology for it.It says that on every page of the blog. And I put it there on every page for a reason.
http://t.co/IRGUsymEef now has a proper code editor, check it out #coldfusion #railo
— cfmldeveloper (@cfmldeveloper) October 9, 2013
savecontent
update: actually not being implemented
savecontent
enhancement request was marked "to fix" (3643125). Unfortunately today the status has been changed to "closed/deferred".savecontent
works currently is correct, and the longer that syntax persists, the more entrenched it's gonna be in people's codebases.savecontent
update
content = savecontent {
// stuff goes here
}
savecontent variable="content" {
// stuff goes here
}
There are quite a few language improvements such as [...] member functions that are already a part of the upcoming versionWhat?! Member functions? COOL.
thread name="t1" action="run" someattribute="value" {
// stuff here
}
t1 = Thread.new({someattribute="value"}) {
// stuff here
}
News and updates from #Adobe on #ColdFusion http://t.co/dyHHz0RJoM
— Rakshith Naresh (@rakshithn) October 1, 2013
Rather than viewing Adobe and community as two separate entities, we are keen to work with the community with a common goal of reviving ColdFusion. And in that context the feedback that we have been receiving is extremely valuable.Well this is good news. I was beginning to get the impression that Adobe didn't really care or pay attention to the community, because... well they seldom seem to, and I think they get a lot of licensing revenue automatically, just as large US companies and govt agencies automatically re-up their licences no matter what Adobe to with ColdFusion. So in that light... perhaps they think they don't need to engage with us developers. We don't pay their bills, after all. This is just supposition, but the impression I get sometimes.
If you are updating a scheduled task via the cfschedule tag it is possible for some of the task info to be reset back to default. For example, if task had an eventhander configured and cfschedule was used to update task but eventhandler attribute was not used then eventhandler would be set to blank. The eventhandler attribute is just one example as this affects other attributes equally.So that's a bit rubbish.
This is by design. As this action re-creates the schedule task. For updating particular attributes of an existing task it is recommended to use admin UIThis is yet another example of Adobe people being bloody jobsworths, IMO. I am gobsmacked by the stunning ignorance of Uday's justification here on two levels: