Re: [Zope3-Users] Pluggable Authentication and SessionCredentialsPlugin

2005-07-16 Thread Darryl Cousins
On Sat, 2005-07-16 at 01:06 -0400, Stephan Richter wrote:
 On Saturday 16 July 2005 00:07, Darryl Cousins wrote:
  So much for my solution, is there a better way. :-)
 
 Of course. :-)

:-) Yes, I should have written **what's** the better way?  :-)

Thanks for that.

Best regards,
Darryl Cousins

 
 from zope.app.security.interfaces import IUnauthenticatedPrincipal
 
 def isLoggedIn(self):
   return not IUnauthenticatedPrincipal.providedBy(self.request.principal)
 
 Regards,
 Stephan
-- 
Darryl Cousins [EMAIL PROTECTED]
Tree Fern Web Services
106 Sandes St
Thames
New Zealand
**64 (0)7 868 3139

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


Re: [Zope3-Users] Pluggable Authentication and SessionCredentialsPlugin

2005-07-15 Thread Stephan Richter
On Thursday 23 June 2005 21:52, Darryl Cousins wrote:
 and as such has **no getLogin method**.

This is correct. zope.security.interfaces.IPrincipal does nto specify a 
getLogin() method.

 I would have expected it to provide InternalPrincipal as it appears to
 in default/PluggableAuthenticatin/principals/testuser/@@introspector

No, the InternalPrincipal is only the data container. A principal is always 
generated for each request. This is a new paradigm in the authentication 
code.

 Any suggestions?

Why do you need getLogin? The id or title of the principal are commonly 
available. The login name is usually protected information.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Pluggable Authentication and SessionCredentialsPlugin

2005-07-15 Thread Darryl Cousins
Hi Stephan,

Thanks for the reply. My purpose was to be able to test for an
authenticated user. My solution was to add a subclass of BrowserView
with the following:

def isLoggedIn(self):

dummy = self.request.principal

pau = getUtility(IAuthentication,'',self.context)
principal = pau.getPrincipal(dummy.id)

if getattr(principal,'id',None) == 'zope.anybody':
return None
else:
return True

this is avalaible in the template as context/@@is_logged_in.

So much for my solution, is there a better way. :-)

Best regards,
Darryl Cousins



On Fri, 2005-07-15 at 14:08 -0400, Stephan Richter wrote:
 On Thursday 23 June 2005 21:52, Darryl Cousins wrote:
  and as such has **no getLogin method**.
 
 This is correct. zope.security.interfaces.IPrincipal does nto specify a 
 getLogin() method.
 
  I would have expected it to provide InternalPrincipal as it appears to
  in default/PluggableAuthenticatin/principals/testuser/@@introspector
 
 No, the InternalPrincipal is only the data container. A principal is always 
 generated for each request. This is a new paradigm in the authentication 
 code.
 
  Any suggestions?
 
 Why do you need getLogin? The id or title of the principal are commonly 
 available. The login name is usually protected information.
 
 Regards,
 Stephan
-- 
Darryl Cousins [EMAIL PROTECTED]
Tree Fern Web Services
106 Sandes St
Thames
New Zealand
**64 (0)7 868 3139

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


Re: [Zope3-Users] Pluggable Authentication and SessionCredentialsPlugin

2005-07-15 Thread Stephan Richter
On Saturday 16 July 2005 00:07, Darryl Cousins wrote:
 So much for my solution, is there a better way. :-)

Of course. :-)

from zope.app.security.interfaces import IUnauthenticatedPrincipal

def isLoggedIn(self):
  return not IUnauthenticatedPrincipal.providedBy(self.request.principal)

Regards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users