[Grok-dev] login event and subscribe to
j.adner at fh-sm.de
Tue Jun 9 09:49:57 EDT 2009
After changing the code to "IAuthenticatedPrincipalCreated", no results.
This event is initiating every view too.
I want write some infos to a mysql database as result of auth event:
uid = principal.id.split('.')[-1]
Currently, every browser request writes the data.
Sebastian Ware schrieb:
> I think you could use the event [IAuthenticatedPrincipalCreated]. Look
> in [zope.app.authentication], the README.txt shares the following:
> Authenticated Principal Creates Events
> We can verify that the appropriate event was published::
> >>> [event] = getEvents(interfaces.IAuthenticatedPrincipalCreated)
> >>> event.principal is principal
> >>> event.info
> >>> event.request is request
> The info object has the id, title, and description of the principal.
> The info
> object is also generated by the authenticator plugin, so the plugin may
> itself have provided additional information on the info object::
> >>> event.info.title
> >>> event.info.id # does not include pau prefix
> >>> event.info.description
> Mvh Sebastian
> 9 jun 2009 kl. 13.50 skrev Jens Adner:
>> I've got a question about the event "IPrincipalCreated".
>> In my app, I use this event for putting a role to a principal:
>> def update_principal_info_from_ldap(event):
>> principal = event.principal
>> prm.assignRoleToPrincipal("adminrole", principal.id)
>> All works fine.
>> But this event is fireing up for every grok view. I need an event for
>> saving some data (login time, logout time, etc.) only for the first
>> successful auth of the user.
>> I don't understand why the principal is creating for every view again
>> and again or why the event "knock on my door".
>> Has anyone some hints? Is there another event I could use for logging
>> user infos at login and logout?
>> ++++++++ Jens Adner IuK-Zentrum Fachhochschule Schmalkalden +++++++++
>> ++++++++ Fon: +49 3683688 9201 Fax: +49 3683688 989201 +++++++++
>> Grok-dev mailing list
>> Grok-dev at zope.org
++++++++ Jens Adner IuK-Zentrum Fachhochschule Schmalkalden +++++++++
++++++++ Fon: +49 3683688 9201 Fax: +49 3683688 989201 +++++++++
More information about the Grok-dev