Hi remi, thanks for the answer... :)
I've used your idea:
# DECORATOR
def protect(group=None):
def entangle(fn):
def protect(func, self, *args, **kwargs):
# some internal validation
if not_validated:
identity.current.logout()
return fn(self, *args, **kwargs)
return protect
return weak_signature_decorator(entangle)
The code above is a copy/paste/adaptation from identity.require decorator.
It worked... but it doesn't solve my problem, because of a requirement
I haven't described in my previous email:
* The system must allow me to know the original identity
* The system must allow me to retrieve a page using an identity X, and
inside this page make some AJAX calls using an identity Y (but the X
identity must be preserved when submitting the form).
I guess I'll have to use a mix of your solution with a subclass of
SqlAlchemyIdentify / SqlAlchemyIdentifyProvider plus a refactoring in
visit_identity table (to allow having multiple identities with the
same visitor_key).
I'm doing some experiments here...
Thanks again for your answer. :)
Roger
On 4/8/07, remi jolin <[EMAIL PROTECTED]> wrote:
>
> Hello Roger,
> Roger Demetrescu a écrit :
> > Hi guys,
> >
> > My coworker is migrating a delphi application into a TG's app. One of
> > the main requests is that everytime the user hits an important screen
> > (aka controller/method), he(she) must enter his(her) username &
> > password.
> >
> > Let me give an example to clarify this scenario:
> >
> > 1) I try to hit the "/" url.. since the entire system demands
> > non_anonymous navigantion, I must provide my identification.. and the
> > current identity becomes "Roger Demetrescu"
> >
> > 2) Then I hit a "/sales/list/' url.. and the system should ask again
> > for the user & password... maybe I enter "RogerDemetrescu / 123", and
> > continue to be the current identity... maybe I enter "Alberto_Valverde
> > / 987" and then he will be the new user... until he hits another url
> > which will ask again for authentication...
> >
> >
> > What's the best way to accomplish this behavior ?
> >
> >
> Why don't you try to logout any current user by executing something
> before "evaluating" the new page ?
> This could (perhaps) be done with a decorator called before all the
> others like
> @logout()
> @expose(...)
> ...
>
> and
>
> def logout():
> def decorator(func):
> def wrapper(*args, **kw):
> # logout any user currently connected
> if identity.not_anonymous():
> identity.current.logout()
> output = func(*args, **kw) # do the page processing
> return output
> return wrapper
> return decorator
>
> I have not tested this (I'm not even sure sure the syntax is correct...)
> I'm not sure it will work but it is worth trying... You would not have to
> change anything in the identity module.
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---