<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=us-ascii" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Martijn,<br>
<br>
thanks for the fast reply!<br>
<br>
<br>
--------------- Here's the version module ----------------------<br>
<br>
<tt>import grok<br>
from interfaces import IVersion<br>
<br>
class Version(grok.Model):<br>
""" Persistent Version """<br>
grok.implements(IVersion)<br>
<br>
def __init__(self, major, minor, v1, v2, v3):<br>
super(Version, self).__init__()<br>
self.major = major<br>
self.minor = minor<br>
self.v1 = v1<br>
self.v2 = v2<br>
self.v3 = v3<br>
<br>
<br>
class Index(grok.DisplayForm):<br>
""" Knows how to display a version """</tt><br>
<br>
<br>
-------------------------------------------------------------------------------------<br>
<br>
<blockquote cite="mid:hjvefi$j71$1@ger.gmane.org" type="cite">
<pre wrap="">Hannes wrote:I've some problem with a schema.Object field when I wanna use grok.AddForm.
Seems like I've to write an Adapter class...?, but unfortunately I don't
know how.... :-(
</pre>
<pre wrap=""><!---->
Hm, it works for edit forms, right? I guess the tricky bit is that you
need objects of the right type to be constructed with an add form. With
an edit form you don't care, you just need to edit the object according
to its schema, whatever object it may be.
I think I've made it work in the past when I *don't* provide a custom
object to create, i.e. I have no Version or Product, but just rely on
the default ObjectWidget to create a default one for me.
Could you show your Version or Product implementation? It looks to me
like these expect multiple arguments to create them. If you changed them
to take no arguments (or created factory functions to do that),
ObjectWidget should be able to create them (call self.factory()).
Looking at the ObjectWidget implementation it should then set the
attributes from your schema directly.
Regards,
Martijn
_______________________________________________
Grok-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Grok-dev@zope.org">Grok-dev@zope.org</a>
<a class="moz-txt-link-freetext" href="https://mail.zope.org/mailman/listinfo/grok-dev">https://mail.zope.org/mailman/listinfo/grok-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>