<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"><page
<br />for="</font></font><font size="2">zope.app.container.interfaces.IAdding</font><font size="2"><font size="2">"
<br />name="AddContent.html"
<br />class=".forms.MyContentAddForm"
<br />permission="zope.ManageContent" />
<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 />>
<font size="2"><b><span style="font-weight: bold;"></span></b>John,
<br />>
<br />> I have never done it with the addform approach but it is very easily done with formlib.
<br />>
<br />> class MyContentAddForm(form.AddForm):
<br />> form_fields = form.Fields(IMyContent)
<br />>
<br />> def __init__(self, context, request):
<br />> self.context = context
<br />> self.request = request
<br />>
<br />> def create(self, data):
<br />> mycontent = MyContent()
<br />> mycontent.title = data['title']
<br />> mycontent.user = self.request.principal.id
<br />> return mycontent
<br />>
<br />> Register it as a page in your config file
<br />>
<br />> <page
<br />> for=".content.MyContent"
<br />> name="AddContent.html"
<br />> class=".forms.MyContentAddForm"
<br />> permission="zope.ManageContent" />
<br />>
<br />> Cheers,
<br />>
<br />> Mats
<br />>
<br />>
<br />> <b>
<br />> On Tue, 20 Jun 2006 22:42:18 +0100 (BST), John Smith wrote</b>
<br />> > Hi,
<br />> >
<br />> > I am trying to add some request related data into a content object (eg authenticated user etc).
<br />> >
<br />> > The content is being added using a normal addform/content_factory zcml approach.
<br />> >
<br />> > The class __init__ method does not receive any arguments, and the context/request pair are only available inside of views.
<br />> >
<br />> > So I am stumped.
<br />> >
<br />> > How do I get at the request object? A utility? An adaptor?
<br />> >
<br />> > Thanks,
<br />> >
<br />> > John
<br />> >
<br />> >
                
<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> . "The New Version is radically easier to use" – The Wall Street Journal
<br />>
<br />>
</font>
<br />
<br />
<br />
</font>
</BODY>
</HTML>