Re: [Zope3-Users] Access request object from content_factory

2006-06-21 Thread Rupert Redington
Hi John,

When I'm looking for the request object from somewhere like that I use

from zope.security.management import getInteraction

request = getInteraction().participations[0]

Why this works is outlined (IIRC) in zope/app/securitypolicy/zopepolicy.txt.

There may well be better ways to fish for the request than this... any
offerings?

Rupert

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Access request object from content_factory

2006-06-20 Thread John Smith
Hi,  I am trying to add some request related data into a content object (eg authenticated user etc).  The content is being added using a normal addform/content_factory zcml approach.  The class __init__ method does not receive any arguments, and the context/request pair are only available inside of views.  So I am stumped.  How do I get at the request object? A utility? An adaptor?  Thanks,  John  
		 
Try the all-new Yahoo! Mail . "The New Version is radically easier to use" – The Wall Street Journal___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Access request object from content_factory

2006-06-20 Thread mats.nordgren




Ooops that should be 

page

for="">zope.app.container.interfaces.IAdding

name=AddContent.html

class=.forms.MyContentAddForm

permission=zope.ManageContent /


Mats


On Tue, 20 Jun 2006 23:37:35 -0500, mats.nordgren wrote
 

John,

 
 I have never done it with the addform approach but it is very easily done with formlib.

 
 class MyContentAddForm(form.AddForm):

   form_fields = form.Fields(IMyContent)

 
   def __init__(self, context, request):

 self.context = context

 self.request = request

 
   def create(self, data):

 mycontent = MyContent()

 mycontent.title = data['title']

 mycontent.user = self.request.principal.id

 return mycontent

 
 Register it as a page in your config file

 
 page

   for=""

   name=AddContent.html

   class=.forms.MyContentAddForm

   permission=zope.ManageContent /

 
 Cheers,

 
 Mats

 
   

 

 On Tue, 20 Jun 2006 22:42:18 +0100 (BST), John Smith wrote

  Hi,

  

   I am trying to add some request related data into a content object (eg authenticated user etc).

  

   The content is being added using a normal addform/content_factory zcml approach.

  

   The class __init__ method does not receive any arguments, and the context/request pair are only available inside of views.

  

   So I am stumped.

  

   How do I get at the request object? A utility? An adaptor?

  

   Thanks,

  

   John

  

   
		

 
Try the all-new Yahoo! Mail . The New Version is radically easier to use – The Wall Street Journal

 
 









___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users