[Zope] Accessing Zope REQUEST data from a Python module

Andreas Jung lists at zopyx.com
Wed Dec 5 22:33:09 EST 2007



--On 5. Dezember 2007 19:35:22 -0500 Ken Winter <ken at sunward.org> wrote:

> I'm customizing a product.  To do what I'm trying to do, I need to be able
> to access REQUEST data from within a Python module (not a script; a .py
> file containing class and method definitions).
>
>> From within a script, a line like
>
> 	req = context.REQUEST
>
> does the job just fine.  But when I put that line into my product module,
> I get a message like:
>
> 	Name "context" not defined
>
> and I don't see any way to import that into my module.

Either you have to pass down the request object down to your own code or 
you pass the current 'context' object down to your code and access the 
request object from their using context.REQUEST. Don't expect that the 
current REQUEST is magically available. So the solution for questions 1-3 
is: pass down the parameters that you need from the location where you have 
them and from where you call your own code (which is likely a script or a 
template).

-aj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20071206/9fe4b778/attachment.bin


More information about the Zope mailing list