[Zope] REQUEST not accessible

Jens Vagelpohl jens at dataflake.org
Thu Oct 13 08:29:22 EDT 2005


On 13 Oct 2005, at 11:56, Jürgen Herrmann wrote:
>> Apart from whether this worked previosuly or not, it is bad coding
>> practice to rely on assumptions such as "it will somehow acquire the
>> REQUEST". You should really change your code to explicity pass in
>> REQUEST everywhere. Then you can stop worrying.
>>
>>
> thanks for the answer, the coding style is one thing, and i don't have
> the least bit of a problem to stick with this in the future (already
> changed all the occurrences anyway to make it work again).
>
> what i'm worried about is wether i did break anything else, possibly
> with even worse results... (i don't like hidden bugs)

By explicitly passing REQUEST? I doubt it.


> btw. is it also bad practice to use self.REQUEST in methods?
> what about def foo(self, REQUEST=None), when and how is REQUEST
> passed there? is it also not a good coding style, if not passing it  
> directly?

The common case is to pass it in explicitly. To pass it in and avoid  
any surprises see the solution discussed above. Explicit is better  
than implicit.

jens



More information about the Zope mailing list