<br><br><div class="gmail_quote">On Mon, May 11, 2009 at 16:35, Martin Aspeli <span dir="ltr"><<a href="mailto:optilude%2Blists@gmail.com">optilude+lists@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Patrick,<br>
<div class="im"><br>
Patrick Gerken wrote:<br>
> Hi,<br>
> while trying to grok Martian, I wanted to try it with a small example.<br>
> The result is a grokker for Elixir schema definitions. It generates<br>
> zope.interfaces with zope.schemas for it, and make the class implement<br>
> some interfaces so that it can be traversed in grok.<br>
<br>
</div>Nice!<br>
<br>
I'm really interested in the first part of that: turning an Elixir class<br>
into a schema interface.<br>
<br>
How did you do it? What conversion algorithm did you use?</blockquote><div><br>First I generated the schema attributes, then I instanciated zope.interface.interface.InterfaceClass.<br>My head is still spinning to really understand that type of metaclass stuff.<br>
I had to add the attrs to the InterfaceClass instanciation so that he does all his stuff with the attributes.<br>After that I actually added the schema attributes to the interface class.<br><br>Maybe this really can't work at all for some reason, but until now, I saw no problems.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">> Whats too unfinished<br>
> - I just made mappers for three different schema types, I do not<br>
> retrieve all attributes from the elixir schema information<br>
<br>
</div>Right. Are you starting from Elixir objects, or the SQLAlchemy table<br>
definitions it presumably generates?</blockquote><div><br>I start from the Elixir objects. They basically do the same that we do with zope interface and schema <br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">
> - I did not dig into relations either, might be complicated, but maybe not.<br>
> - Somehow, my views got loaded to early, before I grokked the model<br>
> data. Also, the dynamically generated interface cannot be easily<br>
> referenced. So an EditForm looks like that currently:<br>
><br>
> class Index(EditForm):<br>
> grok.context(Movie)<br>
> def update(self):<br>
> self.form_fields = grok.Fields(Movie.grokked_interface)<br>
<br>
</div><br>I'd suggest that you stick it in the module as I${class_name} or<br>
something like that, rather than as an attribute on the class.</blockquote><div><br>Yes I will do something like that for sure. <br></div><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> I just wanted to play around with all this stuff, I have no itch<br><div class="im">
> scratching me, so I stop here for now, and look at it at a later time<br>
> again, maybe at the Neanderthalsprint.<br>
><br>
> Meanwhile if somebody has an urgent interest for getting this stuff to<br>
> work, please contact me and I'll clean the stuff up and publish it.<br>
<br>
</div>I'd certainly be interested to see the code.</blockquote><div><br>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.<br>
<br>Best regards, <br><br>Patrick </div></div><br>