Coldfusion on the Google App Engine with Open BlueDragon

ColdFusion, Web Development, BlueDragon, Internet, Google App Engine

The future is now! 

A little melodramatic maybe, but this technology is exciting.  Free cfml app servers with clustering (including data and file storage). 

First, if you don't know what the Google App Engine is yet, go here first and do a little reading.  Once you have read enough of that to be sufficiently excited, we need to set up the development and deployment tools.  Paul Kukiel has put together a really nice demo on how to do this hereNOTE THERE IS ONE THING THAT IS INCORRECT IN THE VIDEO   Do not delete the "war" directory, merely paste the openbd war over the existing one.  This is important.

Next, reading and writing data with the Google datastore. 

Storing data in a scalable web application can be tricky. A user could be interacting with any of dozens of web servers at a given time, and the user's next request could go to a different web server than the one that handled the previous request. All web servers need to be interacting with data that is also spread out across dozens of machines, possibly in different locations around the world.
Thanks to Google App Engine, you don't have to worry about any of that. App Engine's infrastructure takes care of all of the distribution, replication and load balancing of data behind a simple API—and you get a powerful query engine and transactions as well.

Thanks to the fine people at Open BlueDragon, this task is made very very simple.  Every cfc in the openBD GAE inherits the following methods from component.cfc.  GoogleWrite(), GoogleRead(), and GoogleKey().

 

-- Example object Status.cfc:

<cfcomponent displayname="Status" output="false">

	<cfproperty name="Message" displayname="Message" type="string" />
	<cfproperty name="DateTimeCreated" displayname="DateTimeCreated" type="date" />

	<cffunction name="init" access="public" output="false" returntype="Status">
		<cfreturn this/>
	</cffunction>

	<cffunction name="getMessage" access="public" output="false" returntype="string">
		<cfreturn this.Message />
	</cffunction>

	<cffunction name="setMessage" access="public" output="false" returntype="void">
		<cfargument name="Message" type="string" required="true" />
		<cfset this.Message = arguments.Message />
		<cfreturn />
	</cffunction>

	<cffunction name="getDateTimeCreated" access="public" output="false" returntype="date">
		<cfreturn this.DateTimeCreated />
	</cffunction>

	<cffunction name="setDateTimeCreated" access="public" output="false" returntype="void">
		<cfargument name="DateTimeCreated" type="date" required="true" />
		<cfset this.DateTimeCreated = arguments.DateTimeCreated />
		<cfreturn />
	</cffunction>

	
</cfcomponent>

 

-- Writing data to the datastore:

<cfscript>
//saving a new Status to Google datastore
Status = createObject( "component", "model.Status" ).init();
Status.setMessage( "I love Google App Engine and OpenBD!" );
Status.setDateTimeCreated( Now() );

/*now all we do is call the googleWrite() method on our object, notice this returns the objects new google key*/
googleKey = Status.googleWrite();
</cfscript>

 

-- Querying the datastore:  for more on this visit the openBD wiki page on the datastore

<!---
notice dbtype="google" and the quasi-SQL 
--->
<cfquery dbtype="google" name="result">
Select from Status
</cfquery>

<!---
The result of this query, is an array of matching Status objects.  Not the usual query recordset.
--->

 

Securing your new web app with the UserServiceFactory (com.google.appengine.api.users.UserServiceFactory)

Once I figured this step out, it was almost embarassingly easy to secure a page, allowing access only to validated Google account holders.

<cfscript>
UserServiceFactory = CreateObject("java","com.google.appengine.api.users.UserServiceFactory");

User = UserServiceFactory.getUserService().getCurrentUser();

/*Here I am doing a test to see if there is a valid user object returned, aka "logged in".  At this time, I haven't found the ideal solution for this*/

isLoggedIn = false;

try{
   user.getEmail();
   isLoggedIn = true;
}
catch (any excpt){}

</cfscript>

<!---

building login/logut links

--->

<cfif NOT isLoggedIn>
YOU NEED TO <a href="<cfoutput>#UserServiceFactory.getUserService().createLoginURL(toString("http://#cgi.SERVER_NAME#"))#</cfoutput>">LOGIN</a>
<cfelse>
	<cfoutput>#request.user.getEmail()#</cfoutput>:  All your email are belong to us 
	<br />
	<a href="<cfoutput>#UserServiceFactory.getUserService().createLogoutURL(toString("http://#cgi.SERVER_NAME#"))#</cfoutput>">LOGOUT</a>
</cfif>

 

Time to build some real applications.  Early indications from some experimentation by Dave Shuck, are revealing that the Mach-ii MVC framework along with the Coldspring IOC framework are working on the Google App Engine.

Other features, new or otherwise:

 

There is just no reason that we as cfml developers shouldn't be churning out app after app on this platform. 

Tweaking the Content Editor: Adding Images

InstantSpot News

We have always allowed image uploading on InstantSpot, but for too long it has been rather embarassingly complex.  So much so that I bet many didn't even know it was an option.  I have made some changes to the editor (blog/page) to hopefully remedy this situation. 

To commemorate this event, I have uploaded a picture of Conrad and his impossibly small head.

0

Fedor VS Brett Rogers

Miscellaneous, Cool Videos

I'm a big fan of the Adam Carolla podcast, and one of his recent guests was MMA fighter Brett Rodgers.  I don't really follow MMA very closely, but after listening to Brett I was really interested to hear how this fight turned out. Fedor Emelianenko is the #1 ranked fighter in the sport, while Brett just defeated Andrei Arlovski (who according to Brett's trainer was ranked #2). 

 

 

The fight was carried on CBS over the weekend (Nov 7, 2009) and it turned out to be a pretty good one in my opinion.

 

Fedor Emelianenko vs Brett Rogers (FULL FIGHT)

 

Pushing Weight: Back to Basics

Fitness, Pushing Weight

This post is going to be the kick-off for a new series of blog posts tracking my strength and fitness progress.  In the past I have followed complex body-part split routines that focused more on bodybuilding, with a secondary goal of getting stronger. 

Back to Basics is my simple plan.  Eat enough food to keep the scale moving up (.5 lb to 1lb per week) and strive to get stronger in a few basic lifts.  This approach is very different from what I am used to in terms of volume and variation.  As long as strength continues to increase, then I will consider this a successful routine.

The Routine consists of four workout days with a focus on Squat, Deadlift, Bench, Overhead Press. 

Workout 1 - Lower

  • Squat (6 sets / heavy)
  • Deadlift (4 or 5 sets / moderate)
  • Calves

Workout 2 - Upper

  • Bent over Barbell Row ( 3 sets / moderate)
  • Bench (5 sets /  heavy)
  • Overhead Press (4 or 5 sets / moderate)

Workout 3 - Lower

  • Deadlift (5 sets / heavy)
  • Squats (5 sets / moderate)
  • Calves

Workout 4 - Upper

  • Pull - ups (4 sets / bodyweight)
  • Bench (5 sets / moderate)
  • Overhead Press (6 sets / heavy)

 

I have created a log here proglog.instantspot.com to track my progress and updates.

Progressive Overload

Musings, Web Development, Fitness

Progressive Overload is the name of my blog as of yesterday (10/28/09).  I think the concept is extremely important to making gains in the weight room, but there might be some carry-over into other areas of our lives.

Progressive overload is the gradual increase of stress placed upon the body during exercise training. It was developed by Thomas Delorme, M.D. while he rehabilitated soldiers after World War II. This technique is recognized as a fundamental principle for success in various forms of strength training programs including fitness training, weight lifting, high intensity training and physical therapy programs. (from wikipedia)

Moral of the story, if you want to improve in a certain area of your life, never stop pushing yourself...it should always be hard if you want to always get better. 

Ode to Crushed Red Pepper

Musings

I love crushed red pepper and I use it in large quantities every day. 

In fact, I am going to write a haiku about it right now:

 

Oh crushed red pepper

So spicy, hot and awesome

Please never run out

 

tags:
weird

Search

Fuelly