[openstack-dev] OK to Use Flufl.enum

Adam Young ayoung at redhat.com
Tue Dec 10 14:55:50 UTC 2013


On 12/10/2013 05:24 AM, Flavio Percoco wrote:
> On 09/12/13 19:45 -0800, Alex Gaynor wrote:
>> Would it make sense to use the `enum34` package, which is a backport 
>> of teh
>> enum package from py3k?
>
> +1
>
> This is what we were using in Marconi.
So... they seem to be doing something different from Flufl, as IntEnums 
are not working the same way.  I wonder if it is just update lag, and 
Flufl is the Upstream for the changes.

With only a change to the import and requirements, it builds and runs, 
but raises:


Traceback (most recent call last):
   File "keystone/tests/test_revoke.py", line 65, in test_list_is_sorted
     valid_until=valid_until))
   File "keystone/contrib/revoke/core.py", line 74, in __init__
     setattr(self, k, v)
   File "keystone/contrib/revoke/core.py", line 82, in scope_type
     self._scope_type = ScopeType[value]
   File 
"/opt/stack/keystone/.venv/lib/python2.7/site-packages/enum/__init__.py", line 
352, in __getitem__
     return cls._member_map_[name]
KeyError: 1


This seems to say that you cannot access an IntEnum as an integer, which 
just seems broken.


>
>>
>> Alex
>>
>>
>> On Mon, Dec 9, 2013 at 7:37 PM, Adam Young <ayoung at redhat.com> wrote:
>>
>>    While Python 3 has enumerated types, Python 2 does not, and the 
>> standard
>>    package to provide id, Flufl.enum, is not yet part of our code 
>> base.  Is
>>    there any strong objection to including Flufl.enum?
>>
>>    http://pythonhosted.org/flufl.enum/
>>
>>    It makes for some very elegant code, especially for enumerated 
>> integer
>>    types.
>>
>>    For an example See ScopeType in
>>
>> https://review.openstack.org/#/c/55908/4/keystone/contrib/revoke/core.py
>>
>>    Line 62.
>>
>>    the getter/setter in RevokeEvent do not need to do any conditional 
>> logic if
>>    passed either an integer or a ScopeType.
>>
>>
>>    _______________________________________________
>>    OpenStack-dev mailing list
>>    OpenStack-dev at lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>
>>
>>
>>
>> -- 
>> "I disapprove of what you say, but I will defend to the death your 
>> right to say
>> it." -- Evelyn Beatrice Hall (summarizing Voltaire)
>> "The people's good is the highest law." -- Cicero
>> GPG Key fingerprint: 125F 5C67 DFE9 4084
>
>> _______________________________________________
>> OpenStack-dev mailing list
>> OpenStack-dev at lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20131210/bd9d2b2e/attachment.html>


More information about the OpenStack-dev mailing list