Object Oriented Databases with Django

July 21, 2007

Three times over my Django-programming career I've had this same problem. I have a highly polymorphic domain that I'm trying to represent to Django. As is well known in the world of RDBMSes, this leads to very large and complex sets of database tables with correspondingly slow lookup and heavy validation requirements.

Lets, for a simple example, imagine building an ecommerce solution for selling antiques. The antiques we have in stock all belong to one or more categories of antiques. So far so simple: an Antique model with a many to many relationship with a Category model. For each antique we need to store various bits of information: information on its quality, provenance, and damage. But, crucially, the information we need to store for each antique depends on its categories. So for a piece of furniture our shop browsers will expect certain information, while collectors of miniature paintings will expect others.

We could solve this problem by allowing each antique to have any number of properties, and then enter all the relevant information ourselves each time we put a new antique in the system. This would work, but be very error prone: we might forget a salient piece of data. It is also laborious, in most cases there are sensible defaults for propoerties that we'd do well to use. And it begs the question what data type do we store data in? Some properties might be dates, others quality levels, yet others names.

So we could create a fiendishly complex model where categories define certain required parameters, defining their default value and data type, and some flexible parameter table holds the paramaters that are non-default for a particular antique, in such a way that any data can be input (or maybe different parameter tables for different data types). It works but it is very inelegant and laborious to code.

There's got to be a better way.

Continue reading "Object Oriented Databases with Django" »

My Last Post on HTML (Honest)

July 13, 2007

I promise I really will blog about Django and Flex again soon!

There are some major faults with my column-HTML posts below: "If I have seen further it is by standing on the shoulders of giants." -- Newton

Of course, the key part of the quote is that it is a wise move to find some giants and stand on their shoulders. In my case I stood around on tiptoe trying to see as far as possible because I couldn't immediately find a friendly giant to stand on. Thanks for everyone who commented and pointed out where the giants hang out.

So, in summary:

To put columns in any order, don't do the complex nesting stuff I recommended in this post, instead, use negative margins, as described here.

And secondly, don't use a zero pixel div with clear:both that I blogged here, use overlap:hidden in the outer div instead.

So basically, do it differently to the way I said :D

Thanks again everyone for the help.

Welcome Djangoistae

July 10, 2007

It seems the site is listed on the Django main weblog (thanks Clint)!

If you're joining from there and are interested in RIAs, please leave a comment or subscribe. I think it would be great to get together and discuss issues particular to RIAs and django!

A 3 Step Plan for SEO-friendly Rich Internet Applications

July 08, 2007

Search engines are optimised for a non-RIA model of the web: a web made up of pages. SEO tuned web applications expose content in pages for search engines, even if the user will interact with the application through AJAX and page-rewriting (which is completely opaque to a search engine spider).

RIAs make this even harder, and most developers don't seem to bother at all. That's fine if your RIA is going to be used by employees or partners (i.e. people who know where to find it), but not if it will be public facing.

Fortunately, there's an easy way make your RIA search engine friendly.

Continue reading "A 3 Step Plan for SEO-friendly Rich Internet Applications" »

Wrapping a Div around Floats in HTML

July 06, 2007

The second of my digressions onto HTML looks at how to make sure that a DIV is at least as high as the floating DIVs it contains.

If you do something like:

<div id='outer'>
   <div style='float:left'>Content One</div>
   <div style='float:left'>Content Two</div>
   <div style='float:left'>Content Three</div>
</div>

and want div#outer to encompass the three content divs, you find a browser incompatibility. IE7 does that I want - the enclosing div encloses its children. Other browsers do what the CSS standard says is the right thing: div#outer is one pixel high and the rest of the divs descend below it.

enclosing-div-blog.png

I want it to work on all browsers, however. After various playing around I discovered that:

<div id='outer'>
   <div style='float:left'>Content One</div>
   <div style='float:left'>Content Two</div>
   <div style='float:left'>Content Three</div>
   <div style='clear: both; height: 0'></div>
</div>

seems to work. [Interestingly, although I'm working exclusively in XHTML, using <div/> doesn't work - the XHTML spec recommends that you don't have empty tags like div (anything that normally contains content), but this isn't a normative part of the spec, so browsers should really support full XML syntax in this regard.]

The application of all this is that I can now apply a vertically tiled 1px high background image to div#outer, with column shading on it, and have the different height columns all appear to be full-height - something that is very difficult to do by making the floating divs actually the same height. It is a solution that avoids many of the accessibility and fragility problems of the "one true layout" approach.

Combining this with the previous blog post I can now get full-height columns in any order, which is what I needed.

DIV Column Layouts in Any Order (Almost)

July 05, 2007

This is a complete digression for a blog on Django and Flex, I want to talk about some HTML I've been working on. My project is some technology to automatically generate and design web-pages, through my R&D company. There are two things I've discovered, so look out for a further post on the other.

This post is about how to create DIV column layouts where the columns are given in the HTML in any order, but are displayed correctly when rendered, allowing you to have SEO-friendly content first in the HTML page, even if it appears in the middle of your column layout.

Continue reading "DIV Column Layouts in Any Order (Almost)" »

In with the New

July 04, 2007

A quick note to say that I've moved the blog to this new site. Not that there were many folks who'd found it in the five days of its existence, but still.

Advertising

Campaign for Clicks: Support Free Content