[Grok-dev] Elixir ORM Mapper for grok

Martin Aspeli optilude+lists at gmail.com
Tue May 12 05:44:33 EDT 2009

Hi Patrick,

>    I'm really interested in the first part of that: turning an Elixir class
>     into a schema interface.
>     How did you do it? What conversion algorithm did you use?
> First I generated the schema attributes, then I instanciated 
> zope.interface.interface.InterfaceClass.
> My head is still spinning to really understand that type of metaclass stuff.

Actually, this isn't really meta-class stuff. For all intents and 
purposes, an interface is an instance of InterfaceClass (forget the fact 
that it's often instantiated using the 'class' keyword), which is just 
an object that you can cart around as you would any other.

> I had to add the attrs to the InterfaceClass instanciation so that he 
> does all his stuff with the attributes.

It's usually best to create a mapping of attributes and then pass them 
to the InterfaceClass constructor.

Look at plone.supermodel in http://svn.plone.org/svn/plone for some 
examples of doing things with interfaces directly. You may be interested 
in the sync_schema() method in the utils package as well.

> After that I actually added the schema attributes to the interface class.
> Maybe this really can't work at all for some reason, but until now, I 
> saw no problems.

I'm pretty sure it can work. plone.supermodel creates interfaces from 
XML, so this is really no different.

I'm curious how you manage the elixir-column-to-interface-type 
conversation, though.

> I start from the Elixir objects. They basically do the same that we do 
> with zope interface and schema

Is it a 1:1 parity?

> Well, I changed my mind, I didn't to pursue that thing because I had 
> other unfinished things to do. But the whole thing is so interested that 
> I finished the unfinished things finally. I will continue to work on it 
> and release it somewhere in some days.

Excellent. I look forward to seeing it!


Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book

More information about the Grok-dev mailing list