IIS vs onMissingTemplate

Several weeks back I was exposed to Python and Django for the first time, and it really got me thinking. While I'm not a huge fan of Python syntax, I really did like the setup for Django, and how it implements MVC. One of the first things that I loved was this little tid-bit for linking up URL requests to views:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^polls/$', 'mysite.polls.views.index'),
(r'^polls/(?P<poll_id>\d+)/$', 'mysite.polls.views.detail'),
(r'^polls/(?P<poll_id>\d+)/results/$', 'mysite.polls.views.results'),
(r'^polls/(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'),
)

In that block, Django is defining regular expressions that map to Python functions, and defining how to pull named variables out of that regular expression, so that if you requested /polls/23/ becomes a call to the mysite.polls.views module to do the following:

# mysite.polls.views is the module, details is the function
detail(request=<HttpRequest object>, poll_id='23')

Isn't that cool? I'd love to be able to do that in ColdFusion, but it looks like there are a number of hurtles I have to get past before I can make this work:

  1. How do I make ColdFusion get the variables out of that URL path?
  2. How do I make ColdFusion look at a URL that doesn't exist?

 

No Blogs from CFUnited

In case someone out there was wondering, I had to give up on blogging my sessions from CFUnited when my laptop decided to start spazzing out. I'm not sure if I need to download more updates or what, but it would randomly rev my fan, and it was making enough racket that I had to stop using it during sessions.

So much for that.

I did have a blast though. I went 4-2 for stumping Adobe guys on why Peter Bell, who's talks on RAD OO and Code Generation where very nice, and Marc Esher of MXUnit who did an awesome presentation on Ant and its role in managing program deployment.

 

Leveraging Popular Frameworks

This contains info from the CFUnited talk on this topic.

This talk covers MVC, Factories, ORM Introducing a quick start application: AppBooster

Domain & Business objects for each Entity.

Business Object (bean) - people, places, and things, the nouns in your system. Data Access Objects (DAO) - read and save objects Gateways - Objects which return queries Service Object (SO) - your API (controllers do not touch BO, DAO, or Gateway) Controllers - talk to your service layer.

Q: Where is validation at? A: In the BO, or the SO.

Frameworks and Software Layers

DB Layer (ORM) Transfer, Reactor

continue later

 

Adobe Certification

Well, I'm certifiable. Advanced Adobe ColdFusion 7 Certified that is. I passed the test with a score of 93%, which makes me only one questions short of tying for highest score out of my office. What does that mean? Well I can now go to CFUnited this year, and I got a free lunch from my boss.

Time to tack that onto the resumè.

 

Warcraft Killed the Programming Star

Not that I'm really a star, but its true... getting back into playing World of Warcraft has curbed the time I spend tinkering with stuff in the evenings. Expect more about Image.cfc soon though and the extended version which has my current batch of image effects and a few new ones.

 

IsDate() and SQL Server

I don't know about you, but my company uses the IsDate() function for a lot of simple validation of date inputs, and it works fairly well for the most part. The only problem I have with it is that when paired with SQL Server (2000 or 2005), it still can't capture all invalid dates.

The date 'January 5, 753' is a valid date, but attempting to insert it into a SQL Server datetime object throws an error because valid dates for SQL Server are between January 1, 1753 and December 31, 9999. Dates above the year 9999 are caught by IsDate(), but the lower bound is not.


<cffunction name="IsSQLServerDate" returntype="boolean" output="false">
    <cfargument name="date" type="date" required="true"/>
    <cfargument name="type" type="string" required="false" default="datetime"/>

    <cfswitch expression="#arguments.type#">
        <cfcase value="datetime">
            <cfreturn IsDate(arguments.date) AND Year(arguments.date) gte 1753 />
        </cfcase>
        <cfcase value="smalldatetime">
            <cfreturn IsDate(arguments.date) AND DateCompare(arguments.date, '1/1/1900') gte 0 AND DateCompare(arguments.date, '6/2/2079') lte 0 />
        </cfcase>
    </cfswitch>
</cffunction>

Nothing that someone else couldn't write, but useful. to save headaches.

 

More Entries

Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me on LinkedIn.