[openstack-dev] [Ceilometer] Way to get wrapped method's name/class using Pecan secure decorators?
Joshua Harlow
harlowja at outlook.com
Tue Aug 12 16:29:03 UTC 2014
Do u know if ceilometer is using six.wraps?
If so, that helper adds in the `__wrapped__` attribute to decorated
methods (which can be used to find the original decorated function).
If just plain functools are used (and python3.x isn't used) then it
will be pretty hard afaik to find the original decorated function (if
that's the desire).
six.wraps() is new in six 1.7.x so it might not be used in ceilometer
yet (although maybe it should start to be used?).
-Josh
On Tue, Aug 12, 2014 at 9:08 AM, Pendergrass, Eric
<eric.pendergrass at hp.com> wrote:
> Hi, I’m trying to use the built in secure decorator in Pecan for
> access control, and I’ld like to get the name of the method that is
> wrapped from within the decorator.
>
> For instance, if I’m wrapping MetersController.get_all with an
> @secure decorator, is there a way for the decorator code to know it
> was called by MetersController.get_all?
>
> I don’t see any global objects that provide this information. I
> can get the endpoint, v2/meters, with pecan.request.path, but
> that’s not as elegant.
>
> Is there a way to derive the caller or otherwise pass this
> information to the decorator?
>
> Thanks
> Eric Pendergrass
More information about the OpenStack-dev
mailing list