CloudDB update

The ComputeristSolutions site has been running with CloudDb for several weeks now and its going well. I don’t even think about it mostly, unless I want to change some content using the CloudDB web interface. Our implementation checks for content from clouddb for each page, and falls back to local content if its not available. The exception is the purely dynamic pages, which are based on pages in a certain path like this one.

The csinc site is built on Castle Monorail, an MVC framework.  The base controller defines a method to look up whether dynamic content is available and then loads it. Otherwise the method processes normally and the local file is shown. To handle the dynamic pages, I added a route that translates anything looking like /pages/{pagename}.ashx to /content/page.ashx?name={pagename}. Then either the dynamic content is show or a 404 page if no content available.

I previous covered how we access clouddb data. Here is some sample code for handling the dynamic pages:

Routing:

<monorail smtpHost="xxx" useWindsorIntegration="false">
		<controllers>
			<assembly>xxx</assembly>
		</controllers>
		<viewEngines viewPathRoot="Views">
			<add xhtml="false" type="Castle.MonoRail.Framework.Views.
                        NVelocity.NVelocityViewEngine, Castle.MonoRail.Framework.Views.NVelocity"/>
		</viewEngines>
		<routing>
			<rule>
				<pattern>^(/pages/)(\w+)(.ashx)*$</pattern>
				<!--pattern>^(/pages/sample.ashx)(.)*$</pattern-->
				<replace><![CDATA[ /content/page.ashx?name=$2 ]]></replace>
			</rule>
		</routing>
	</monorail>

 

Content controller

public class ContentController : BaseController
	{
		public void Page()
		{
			string contentName = Request.QueryString["name"];
			if (contentName == null || contentName.Trim().Length == 0)
			{
				Show404();
				return;
			}

			//show content or render blank; will have to change this to throw a 404
			if (!ShowDynamicContent(contentName))
				Show404();
		}
	}

That’s it; pretty easy. I’d recommend clouddb although I’m still feeling out what situations it’s best for. It’s certainly working out great as a lite CMS for our site.

 
January 7, 2010 10:35 by josh
E-mail | Permalink
blog comments powered by Disqus


about josh

another programmer blogging about his misadventures in writing code.

Contact

contact us for website & software consulting

Decide

decide on pragmatic solutions

Develop

develop your product together

Succeed

achieve your goals with our services