Another BIG Milestone: For/Empty tags and the start of Blogs

Armed with my new template variable and OPF systems I've built a simple module to store and retrieve webpages by URL in a database. Its reminiscent of the Django "flatpages" app. This works pretty good. I have moved the "coming soon" page into the DB using this new module.

I figured a good exorcise for the system and the next piece that I wanted was a basic blog. But this required a couple more major pieces: A variable reference system and lists with a way to iterate through them.

I developed a variable reference type and associated API to allow template tags access to context values, objects and their properties, regardless of type or how they're stored. These require two very different methods of access. The first application of that was an if/else tag for conditional display.

Next I looked for things within FPC that could be leveraged for a generic iterable type within a context. But I didn't find anything suitable. I figured with the compiler's newer for ... in ... do syntax there would be a generic iterator interface I could leverage. But their implementation requires information from compile-time which the template context system won't have.

So I settled on a specific class ancestor that stores a list of objects. Since I wanted to implement all of the loop variables that the Django for tag provides this needed to be a finite indexable list not an open ended one. This requirement shaped the API. Any descendant class need only provide two thing: a get() function to return an object by index and count() function to return the number of objects in the list.

So with my new tags and template capabilities I created two new models for the blog and its child pages. Both of these are subclasses of the webpage model mentioned above. Being that my models are simple objects I can do that without special machinery. I then created subclasses of the basic SQL table container to put class specific retrieval and storage logic into.

Add to that a couple templates and this blog was born. And I now have a complete, albeit bare, mechanism for presenting data from a database. To make the blog module work the way I envision it I'll need to add wild-cards to my URL routing.

Off to write these past blog entries your reading....