[openstack-dev] [nova] is it possible to microversion a static class method?

Chen CH Ji jichenjc at cn.ibm.com
Thu Mar 12 21:33:12 UTC 2015

Know it's a little bit tricky but from
can we make _version_specific_func static function thought it's not
required or we can explicitly suggest not to do so...

 91     @api_version("2.1", "2.4")
 92     def _version_specific_func(self, req, arg1):
 93         pass
 95     @api_version(min_version="2.5") #noqa
 96     def _version_specific_func(self, req, arg1):
 97         pass
 99     def show(self, req, id):
100         .... common stuff ....
101         self._version_specific_func(req, "foo")
102         .... common stuff ....

Best Regards!

Kevin (Chen) Ji 纪 晨

Engineer, zVM Development, CSTL
Notes: Chen CH Ji/China/IBM at IBMCN   Internet: jichenjc at cn.ibm.com
Phone: +86-10-82454158
Address: 3/F Ring Building, ZhongGuanCun Software Park, Haidian District,
Beijing 100193, PRC

From:	Sean Dague <sean at dague.net>
To:	openstack-dev at lists.openstack.org
Date:	03/12/2015 07:16 PM
Subject:	Re: [openstack-dev] [nova] is it possible to microversion a
            static class method?

On 03/12/2015 02:03 PM, Chris Friesen wrote:
> Hi,
> I'm having an issue with microversions.
> The api_version() code has a comment saying "This decorator MUST appear
> first (the outermost decorator) on an API method for it to work
> I tried making a microversioned static class method like this:
>     @wsgi.Controller.api_version("2.4")  # noqa
>     @staticmethod
>     def _my_func(req, foo):
> and pycharm highlighted the api_version decorator and complained that
> "This decorator will not receive a callable it may expect; the built-in
> decorator returns a special object."
> Is this a spurious warning from pycharm?  The pep8 checks don't complain.
> If I don't make it static, then pycharm suggests that the method could
> be static.

*API method*

This is not intended for use by methods below the top controller level.
If you want conditionals lower down in your call stack pull the request
version out yourself and use that.


Sean Dague

OpenStack Development Mailing List (not for usage questions)
Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150312/7a02c325/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150312/7a02c325/attachment.gif>

More information about the OpenStack-dev mailing list