Thoughts on BasicProperty in the morning (How to unify the dozens of domain-modelling descriptor libraries?)
Written by
on
in
Snaking.
As I covered in my talk this past PyCon, we're getting a proliferation of domain-modelling frameworks in Python. I'm actually responsible for 2 of them myself (OpenGLContext's fields and BasicProperty). There's also Traits, Zope's fields, and a similar system in PEAK.
When you consider PyTable (which creates BasicProperty properties from database-schema definitions and builds convenience methods from them), then you add SQLObject, DJango, and probably half a dozen other Object-Relational mappers which are "almost the same thing".
So, what really seems to be needed is a way to unify the whole set. Take the common features, and the usefully distinctive features, and create a single, rational, well-thought-out domain-modelling property type. It will need to have optional observability, type-checking, constraints, default values, the ability to house database-specific information, friendly names, delegation support, easily overridden storage mechanisms, easily overridden coercian, and reasonable speed.
BasicProperty already has most of that. It needs a better mechanism for overriding coercion at the property level (right now it always relies on the baseType). It needs a better observability story, namely it needs to have the option for pre-set and post-set messages built-in. It needs the ability to generate property ordering, likely with a special class/metaclass that takes a simple list-of-properties and moves them into the class, noting their position (or alternately, give every property created a creation timestamp and simple sort those in a class by it when needing an order).
The delegation is easy, in fact, so easy that I normally write it whole-cloth for each property (lambda prop,client: client.someProp.someValue), but maybe making it explicit and obvious would be a good thing i.e. delegateTo = ('someProp','someValue' ). Yes, something would be useful, particularly to get rid of the ambiguity of declaring a default with no caching on default when a delegate is intended.
Anyway, the thing that really seems to be missing, however, is the set of support mechanisms; drag and drop editors to produce domain models with all of the various features selected from a palette; multiple "propertied" classes to provide various modelling types... effectively just a typology of property use patterns (e.g. constrain attributes to properties or not, display __repr__ as a full property-by-property display, ordered or unordered properties); a "web framework" like Django with default editing tools (I already have one for BasicProperty, but it'd be better to use an already published and running one, rather than recreating it); and a (couple of) GUI-library bindings (e.g. wxoo, but finished ;) ).
Enough rambling. Time to start the day.
Pingbacks
Pingbacks are closed.
Comments
Comments are closed.