[Zope-dev] makerequest.py

Chris McDonough chrism@digicool.com
Fri, 27 Apr 2001 12:17:58 -0400


> Hi,
>
> This is quite a useful little utility, but it creates a REQUEST object
without
> any AUTHENTICATED_USER beign present.

Uh huh.

>
> Should this be remedied? If so, how?

Maybe it should be a parameter of the makerequest function.

> I do have memories that REQUEST.AUTHENTICATED_USER has been deprecated. In
> which, case, how should you get hold of the current user's object and can
this
> be made to work in a testing environment?

from AccessControl import getSecurityManager
user = getSecurityManager().getUser()

And yes, this can be made to work in a testing environment.  You'll always
get the Anonymous User from within a test, however.

For an example of a way to *set* the user with the same facility, see
CoreSessionTracking's SessionDataManager.EventWrapper.__call__ method.

> Nirvana here would be not having to import Zope so that we can run tests
while
> Zope is still up and running in a non-ZEO situation.
> Does ZUnit help with this? If so, how?

Dunno.  It's not really possible if you depend on database operations.  This
is why it's important to factor your products into bits testable outside of
the Zope framework.