My previous host has had issues with their server and I felt it was time to move on. So I'm on a new host with a fresh MangoBlog install. New posts are inevitable, but the good stuff from my [old] blog will be migrated soon. Hopefully, this crash and re-incarnation hasn't been a thorn to anyone.
This is just a quick post about the <cfqueryparam/> and cf_sql_type to use with when working with Microsoft SQL Server (MSSQL) money datatype. While working on a recent project the client specified the db schema and I had to work with a predefined schema. I typically don't use the money datatype, when designing a db schema, preferring instead to use decimal(8,2) for fields where I'm storing monetary data. As we began loading data into a table with money as the datatype, we noticed that amounts like 129.99 were being rounded up to 130. The ColdFusion 9 reference for <cfqueryparam/> does not mention the money datatype, but recommends using cf_sql_money for the double datatype. The ColdFusion 8 reference suggests using the cf_sql_decimal type when storing data to decimal, money, smallmoney mssql datatypes. I followed the suggestion in the CF8 reference, but ran into the rounding error. Finally, I was hipped to the correct cf_sql_type to use by my good friend Matt Quackenbush. He's experienced the same issue in the past and informed me that the solution is to use cf_sql_float.
Today, I was able to get https working for localhost connections after following these step by step instructions for creating and signing a cert and updating httpd.conf and httpd-ssl.conf on Mac OS X Hints. Problem is, I need https for vhosts. When trying to connect to a local vhost over https, I encountered the following error: Error code: ssl_error_rx_record_too_long). Much more googling turned up the answer. You need to turn the SSLEngine On for vhosts. Thanks to the Ubuntu forums for that gem. Here's an example vhost that uses SSL.
<VirtualHost 127.0.0.1:443>
DocumentRoot "/Users/paul/Sites/myproject"
ServerName myproject.fancybread.local
SSLEngine On
SSLCertificateFile "/Users/paul/certs/localhost/newcert.pem"
SSLCertificateKeyFile "/Users/paul/certs/localhost/localhost.nopass.key"
DirectoryIndex index.cfm
<Directory "/Users/paul/Sites/myproject">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Logging is one of the classic cross-cutting concerns one hears about when discussing Aspect Oriented Programming (AOP). Other common aspects are caching, security and data transformation. Over the past year, I've begun to apply AOP with ColdSpring to my application design. I was completely confused about just what was going on with AOP, when I first looked at it, then, by degrees, I came to realize that it is actually pretty simple if you can focus on the basics without trying to absorb all the terms associated with AOP. With the release of ColdSpring 1.2, Brian Kotek wrote an excellent quickstart guide, that I recommend (especially for the AOP tutorial which I borrow heavily from for this example). I'll briefly describe how I wrapped my head around the concept.
I've started using Coldbox recently and really like the tooling it provides. I don't always have access to the ColdFusion logs for apps on shared servers and although I have worked with log4j, I didn't like property file configuration. The simplicity of the ColdBox logger is great, but I wanted to be able to set log levels and work with the standard debug(), info(), warn(), error() and fatal() methods. One way to achieve this is to mixin the desired behaviour. Another ColdBox plugin, methodInjector, allowed me to do just that.
Maintaining referential integrity in your database is a good thing. Any decent RDBMS will include ACID (Atomicity, Consistency, Isolation, Durability) transaction support for ensuring consistency and recoverability of your database. With the Transfer ORM Transaction object, one can apply transactions easily to a Service or Gateway. Here's how one can use it to wrap all "save" and "delete" methods for a Service.
For the migration to Mango Blog, I wanted to preserve my previous RSS feed location (/rss.cfm). The new location is feeds/rss.cfm. With the availability of onMissingTemplate event handler for ColdFusion 8, making sure my RSS didn't break was a snap. Here's the snippet of code I added to Application.cfc.
<cffunction name="onMissingTemplate" returntype="void">
<cfargument name="thePage" type="string" required="true">
<cfif arguments.thePage is "/blog/rss.cfm">
<cflocation url="/blog/feeds/rss.cfm" addtoken="false" />
</cfif>
</cffunction>
Not the most elegant solution I've ever developed, but it keeps the RSS feed alive until I decide how I want to manage it the future...