On Wednesday 31 January 2007 05:28, Maciej Wisniowski wrote:
> In doc test I may use:
> >>> request = TestRequest()
> >>> class User(object):
> ... id = 'Jan'
> ... title = 'Jan Kowalski'
> >>> request.setPrincipal(User())
> ..........rest of the test......
> and after this everything works.
> Is this correct way?
Sure, whatever it takes to get it to work. :-)
> I also have some code that uses:
> from zope.app.security.interfaces import ILoginPassword
> During tests, I always get None as result of the above
> So another question, what is the correct way to
> get currently authenticated principal id:
> request.principal.id or ILoginPassword(self.request).getLogin()?
I use request.principal.id. Note that principal.id != principal.login
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
Zope3-users mailing list