Shortcut
lumi_filter.shortcut
Shortcut utilities for automatic model generation and request argument compatibility.
This module provides convenience utilities for automatically generating filter models from data sources and handling different request argument formats.
Classes:
Name | Description |
---|---|
AutoQueryModel |
Automatically generates filter models from data structure |
Functions:
Name | Description |
---|---|
compatible_request_args |
Converts alternative syntax to standard lookup format |
Supported Data Sources
- Peewee ORM ModelSelect queries
- Iterable data structures (list of dictionaries)
- Nested dictionary structures with dot notation support
Alternative Syntax Mappings
- == -> (exact match)
- != -> ! (not equal)
-
= -> __gte
- <= -> __lte
-
-> __gt
- < -> __lt
- LIKE -> __in (contains)
- ILIKE -> __iin (case-insensitive contains)
AutoQueryModel
Automatic query model generator.
This class automatically generates filter models based on the structure of the provided data source, supporting both Peewee ORM queries and iterable data structures.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
The data source to generate model from |
required | |
request_args
|
dict
|
Request arguments for filtering |
required |
Source code in lumi_filter/shortcut.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
compatible_request_args(request_args)
Convert request arguments to compatible format.
This function converts request arguments from alternative syntax formats to the standard lookup expression format used by the filter system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request_args
|
dict
|
Dictionary of request arguments in alternative format |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Dictionary of converted request arguments |
Raises:
Type | Description |
---|---|
ValueError
|
If unsupported lookup expression is encountered |
Source code in lumi_filter/shortcut.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|