[openstack-dev] [Ceilometer] Way to get wrapped method's name/class using Pecan secure decorators?

Pendergrass, Eric eric.pendergrass at hp.com
Tue Aug 12 16:46:11 UTC 2014


Thanks Ryan, but for some reason the controller attribute is None:

(Pdb) from pecan.core import state
(Pdb) state.__dict__
{'hooks': [<ceilometer.api.hooks.ConfigHook object at 0x31894d0>, <ceilometer.api.hooks.DBHook object at 0x3189650>, <ceilometer.api.hooks.PipelineHook object at 0x39871d0>, <ceilometer.api.hooks.TranslationHook object at 0x3aa5510>], 'app': <pecan.core.Pecan object at 0x2e76390>, 'request': <Request at 0x3ed7390 GET http://localhost:8777/v2/meters>, 'controller': None, 'response': <Response at 0x3ed74d0 200 OK>}

> -----Original Message-----
> From: Ryan Petrello [mailto:ryan.petrello at dreamhost.com]
> Sent: Tuesday, August 12, 2014 10:34 AM
> To: OpenStack Development Mailing List (not for usage questions)
> Subject: Re: [openstack-dev] [Ceilometer] Way to get wrapped method's name/class using Pecan secure decorators?
>
> This should give you what you need:
>
> from pecan.core import state
> state.controller
>
> On 08/12/14 04:08 PM, Pendergrass, Eric 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
>
> > _______________________________________________
> > OpenStack-dev mailing list
> > OpenStack-dev at lists.openstack.org
> > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
> --
> Ryan Petrello
> Senior Developer, DreamHost
> ryan.petrello at dreamhost.com
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev



More information about the OpenStack-dev mailing list