Initial commit after converting project to SQLAlchemy and Pyramid
I'm not happy about this but ultimately django's lack of support for
custom database schemas had caused too serious problems for it to be
worth the effort. Django is clearly not made to be able to comfortably
interact with a mildly complicated preexisting relational database.
Django's ORM is little more than an object persistence layer that looks
at the relational database backend as an implementation detail.
Composite primary keys are plain not supported at all. Certain structure
is expected and anything else is badly supported. Many-to-many
relationships that are not implemented like the ORM expects are hard. Each
object represents exactly one row in one table and it is not supported to
deviate from that. These and many other issues have cost a lot of time and
productivity.
It was my conclusion that django's ORM had to be replaced with SQLAlchemy.
Much of django, including:
*the authentication framework
*flatpages and the other "batteries included"
*the admin interface
*most reusable apps
are tightly coupled to the django ORM and thus we would lose those if we
tried to replace it with SQLAlchemy. Additionally, there is little
published experience on using django with SQLAlchemy so that option
might be full of surprises.
Django's admin interface also proved too inflexible for the data, most
notably due to inlines not being nestable and inlines are required for
basic things like a (normalized, thus using a table for itself) list of
names inside a model.
Thus facing inability to use almost all of django's good features and
having to convert the whole project anyway, I decided to leave django
out of it for good. I picked pyramid to fill it's place due to it being
perhaps the biggest and best supported project to use with SQLAlchemy
and having roots in repoze and Zope, it is well structured for the kind
of flowing organization data where the data is more important than the
application.
The new template system is jinja2 which is basically a better designed
almost-compatable version of django's templating system and most our
templates work with minimal modifications and the cost of that part of
the conversion is practically zero. Dispatch was also chosen instead of
traversal even though traversal might suit this project better due to
dispatch being almost a drop-in replacement for django's url
configuration and traversal requiring major architectural changes.
The templates, css and javascript from django's admin interface will be
reused to prevent having to rewrite it. As features are added and
designs change, it is expected to be phased out. Form generation is now
handled by the formalchemy library.
Overall time lost to the conversion is about 3-4 days, which is less
than the time lost already to fighting django.