[PEAK] Persistence styles, MDA, AOP, PyProtocols, and PEAK

Robert Brewer fumanchu at amor.org
Wed Jul 7 17:29:20 EDT 2004


Stephen Waterbury wrote:
> BTW, I am making some changes to my app right now to make it more
> "ontology-driven" as regards domain objects and their persistence.
> Sort of a "limited MDA".  This is strongly motivated by several of
> the use cases for my app, which involve ontologies.
> 
> idea ... in a nutshell:
> 
> * "OntoClass" instances, which are subclasses of dict
> * "OntoProperty" instances that have a name, type_name,...
> * The app domain object classes all have a '_schema' attribute
> which is an OntoClass instance, of which the OntoProperty
> instances are used in __init__ to create instance attributes.
> (I'm not using metaclasses to do this yet, but might do that
> in the future ... trying to keep this as simple as possible
> for now.  ;)

Why separate the domain object from the OntoClass? In other words, why
would an Invoice class "have a" schema rather than "be a" schema?

> * OntoClass instances implement a very simple (ontology-like)
> form of OntoProperty inheritance (from their _OntoClass__base).
> So new domain object classes, as long as they do not require
> new behaviors (as is often the case for the objects that my
> app deals with), can be created simply by assigning a new
> OntoClass instance that extends the _schema for an object
> (this is done for instances only -- class _schema's are not
> to be changed).
> 
> * The main motivation for this form of extensibility is to
> enable the repository's database to be built from the
> OntoClasses, which are registered in a registry module and
> can be changed at runtime.  The registry is also used in
> the marshalling/unmarshalling and repository add/modify
> interfaces.
> 
> I think it is the "simplest possible thing that works"
> (in some sense of "works" ;) for my app, and in keeping it as
> simple as possible, I'm hoping that conversion to the more
> sophisticated PEAK architecture won't be too difficult
> at some point in the future.
> 
> Comments welcome!

I did basically the same thing you describe above, for the same reasons.
You can check out the core at
http://www.aminus.org/rbre/python/dejavu/__init__.py (and other files in
that folder). My "OntoClass" is called "Unit", and "OntoProperty" is
called "UnitProperty" (a descriptor). You can see how the DB tables get
created (for ADO DB's) in
http://www.aminus.org/rbre/python/dejavu/storage/storeado.py

Steal whatever you like. I don't use Twisted (yet), but I did use a tiny
bit of metaclassing. ;)


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org



More information about the PEAK mailing list