Either add it to func within (inner) require(), or to the result of decorator():
newfunc = decorator(require)(fn) newfunc._require = ... return newfunc Cheers, Simon Jeff Watkins wrote: > Simon, I've been trying to add this feature and it doesn't seem to work > correctly. The require decorator is presently defined as: > > def require(predicate, obj=None): > ''' > Function decorator that checks whether the current user is a member > of the > groups specified and has the permissions required. > ''' > def entangle(fn): > def require(func, self, *args, **kwargs): > try: > errors= [] > if predicate is None or \ > predicate.eval_with_object(current, errors): > return fn(self, *args, **kwargs) > except IdentityException, e: > errors= [str(e)] > > raise IdentityFailure(errors) > return decorator(require)(fn) > return entangle > > I've tried adding a _require attribute to entangle or the internal > require, but in neither case is it visible as part of the decorated > method. The magic seems to have failed. Any idea what I might be doing > wrong? > > On 18 Feb, 2006, at 5:38 am, Simon Belak wrote: > >> >> Jeff Watkins wrote: >>> Wow. That's a really interesting idea. I could easily expose the >>> permission predicate that the require decorator is using, however, I >>> don't think that would work, because later decorators would hide that >>> information. >>> >>> Anyone with deeper Python-fu who'd like to make a suggestion? >> >> Depends how you intend to expose it. It should work if you make it an >> attribute (as long as everyone is using "well behaved" decorators). >> >> We can of curse also tweak the decorator library if you have any special >> needs (preferably in a way useful to others as well). >> >> >> Cheers, >> Simon >> >> >> >> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~----------~----~----~----~------~----~------~--~---