<br><br><div class="gmail_quote">On Mon, May 11, 2009 at 16:35, Martin Aspeli <span dir="ltr">&lt;<a href="mailto:optilude%2Blists@gmail.com">optilude+lists@gmail.com</a>&gt;</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>
&gt; Hi,<br>
&gt; while trying to grok Martian, I wanted to try it with a small example.<br>
&gt; The result is a grokker for Elixir schema definitions. It generates<br>
&gt; zope.interfaces with zope.schemas for it, and make the class implement<br>
&gt; some interfaces so that it can be traversed in grok.<br>
<br>
</div>Nice!<br>
<br>
I&#39;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&#39;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">&gt; Whats too unfinished<br>
&gt; - I just made mappers for three different schema types, I do not<br>
&gt; 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">
&gt; - I did not dig into relations either, might be complicated, but maybe not.<br>
&gt; - Somehow, my views got loaded to early, before I grokked the model<br>
&gt; data. Also, the dynamically generated interface cannot be easily<br>
&gt; referenced. So an EditForm looks like that currently:<br>
&gt;<br>
&gt; class Index(EditForm):<br>
&gt;     grok.context(Movie)<br>
&gt;     def update(self):<br>
&gt;         self.form_fields = grok.Fields(Movie.grokked_interface)<br>
<br>
</div><br>I&#39;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;">

&gt; I just wanted to play around with all this stuff, I have no itch<br><div class="im">
&gt; scratching me, so I stop here for now, and look at it at a later time<br>
&gt; again, maybe at the Neanderthalsprint.<br>
&gt;<br>
&gt; Meanwhile if somebody has an urgent interest for getting this stuff to<br>
&gt; work, please contact me and I&#39;ll clean the stuff up and publish it.<br>
<br>
</div>I&#39;d certainly be interested to see the code.</blockquote><div><br>Well, I changed my mind, I didn&#39;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>