Skip to content

Provide parameter to override integer range on EnumField. #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bckohan opened this issue Apr 11, 2023 · 0 comments
Closed

Provide parameter to override integer range on EnumField. #38

bckohan opened this issue Apr 11, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bckohan
Copy link
Member

bckohan commented Apr 11, 2023

This is needed for flag fields where users want to pack more information into the most significant bits. For instance, consider the following flag enum:

class DataRate(IntFlagProperties, s('label'), s('slug', case_fold=True)):

    DAILY  =  2**1, 'Daily',     'daily'
    HOURLY =  2**2, 'Hourly',    'hourly'
    HIGH_RATE  =  2**3, 'High Rate', 'high'

    # bits 4-16 are reserved for daily data rate in seconds

    # bits 17-27 are reserved for hourly data rate in seconds

    # bits 28-32 are reserved for high rate data rate in seconds

This flag qualifies rates into categories, but for each category a higher resolution period in seconds can be packed into the msbs. EnumField would only see the three flags and use a SmallPositiveInteger for this field. The user should be able to override this behavior with something like EnumField(DataRate, bit_length=32) to force EnumField to pick PositiveIntegerField instead.

@bckohan bckohan self-assigned this Apr 11, 2023
@bckohan bckohan added the enhancement New feature or request label Apr 11, 2023
bckohan added a commit that referenced this issue May 1, 2023
@bckohan bckohan added this to the Version 2.0 milestone May 1, 2023
@bckohan bckohan closed this as completed Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant