<HTML>
<HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="Open WebMail 2.10 20030617" name=GENERATOR>
</HEAD>
<BODY bgColor=#ffffff>

<font size="2">Ooops that should be 
<br />
<br /></font><font size="2"><font size="2">&lt;page

<br />for=&quot;</font></font><font size="2">zope.app.container.interfaces.IAdding</font><font size="2"><font size="2">&quot;

<br />name=&quot;AddContent.html&quot;

<br />class=&quot;.forms.MyContentAddForm&quot;

<br />permission=&quot;zope.ManageContent&quot; /&gt;

<br />
<br />Mats
<br /></font></font>
<br /><font size="2"><b>
<br />On Tue, 20 Jun 2006 23:37:35 -0500, mats.nordgren wrote</b>
<br />&gt; 

<font size="2"><b><span style="font-weight: bold;"></span></b>John,

<br />&gt; 
<br />&gt; I have never done it with the addform approach but it is very easily done with formlib.

<br />&gt; 
<br />&gt; class MyContentAddForm(form.AddForm):

<br />&gt;   form_fields = form.Fields(IMyContent)

<br />&gt; 
<br />&gt;   def __init__(self, context, request):

<br />&gt;     self.context = context

<br />&gt;     self.request = request

<br />&gt; 
<br />&gt;   def create(self, data):

<br />&gt;     mycontent = MyContent()

<br />&gt;     mycontent.title = data['title']

<br />&gt;     mycontent.user = self.request.principal.id

<br />&gt;     return mycontent

<br />&gt; 
<br />&gt; Register it as a page in your config file

<br />&gt; 
<br />&gt; &lt;page

<br />&gt;   for=&quot;.content.MyContent&quot;

<br />&gt;   name=&quot;AddContent.html&quot;

<br />&gt;   class=&quot;.forms.MyContentAddForm&quot;

<br />&gt;   permission=&quot;zope.ManageContent&quot; /&gt;

<br />&gt; 
<br />&gt; Cheers,

<br />&gt; 
<br />&gt; Mats

<br />&gt; 
<br />&gt;   

<br />&gt; <b>

<br />&gt; On Tue, 20 Jun 2006 22:42:18 +0100 (BST), John Smith wrote</b>

<br />&gt; &gt; Hi,

<br />&gt; &gt; 

<br />&gt; &gt;  I am trying to add some request related data into a content object (eg authenticated user etc).

<br />&gt; &gt; 

<br />&gt; &gt;  The content is being added using a normal addform/content_factory zcml approach.

<br />&gt; &gt; 

<br />&gt; &gt;  The class __init__ method does not receive any arguments, and the context/request pair are only available inside of views.

<br />&gt; &gt; 

<br />&gt; &gt;  So I am stumped.

<br />&gt; &gt; 

<br />&gt; &gt;  How do I get at the request object? A utility? An adaptor?

<br />&gt; &gt; 

<br />&gt; &gt;  Thanks,

<br />&gt; &gt; 

<br />&gt; &gt;  John

<br />&gt; &gt; 

<br />&gt; &gt;  
                

<hr size="1" /> 
Try the <a href="http://us.rd.yahoo.com/mail/uk/taglines/default/nowyoucan/wall_st_2/*http://us.rd.yahoo.com/evt=40565/*http://uk.docs.yahoo.com/nowyoucan.html">all-new Yahoo! Mail</a> . &quot;The New Version is radically easier to use&quot; – The Wall Street Journal

<br />&gt; 
<br />&gt; 
</font>

<br />
<br />
<br />
</font>
</BODY>
</HTML>