What is pyDictStore
pyDictStore adds automated dictionary storage to properties eliminating the need for code bodies, property getters and setters. It also provides a property change event.
Minimum usage
The minimum usage of this library requires you to add the @storage decorator to your class. This will automatically wrap your properties with the auto storage capabilities. The default value applied to any property is None. To override this, you will need to apply the @default decorator to your propperty's getter.
@storage
class ExampleClass():
@property
def exampleProperty(self): ...
@exampleProperty.setter
def exampleProperty(self,value): ...
...with default value
@storage
class ExampleClass():
@property
@default(10)
def exampleProperty(self) -> int: ...
@exampleProperty.setter
def exampleProperty(self,value) -> None: ...
Overriding the getter and setter
getter
If the getter returns a value other than None it will override the value pulled by pyDictStore. The example below will result in the property always returning 12.
@storage
class ExampleClass():
@property
@default(10)
def exampleProperty(self) -> int:
return 12
setter
Overriding the setter allows you to modify the value that is saved into storage. This is helpful if you need to perform logic against the value being passed in or if you want to force the storage type; such as parsing an integer from a string or storing a Boolean value as an integer. To do this requires ignoring normal setter conventions by using a return statement.
⚠️ Warning: Overriding the output does not work if you return a value of None.
@storage
class ExampleClass():
@property
@default(10)
def exampleProperty(self) -> int: ...
@exampleProperty.setter
def exampleProperty(self,value) -> None:
return value * 3
Event Handling
When the setter of a property is called it will raise a PropertyChanged Event within your class. This provides you the instance of the class that raised the event, the name of the property, the previous value, and the new value.
💡 Note: When the default value is instantiated the PropertyChanged event does not fire.
...event handler within class
@storage
class ExampleClass():
def __init__(self) -> None:
self.PropertyChanged += self.onPropertyChanged
@staticmethod
def onPropertyChanged(sender, name:str, oldValue, newValue):
... #Your Custom Action here
@property
@default(10)
def exampleProperty(self) -> int: ...
@exampleProperty.setter
def exampleProperty(self,value) -> None: ...
...event handler external from class
def onPropertyChanged(sender, name:str, oldValue, newValue):
... #Your Custom Action here
@storage
class ExampleClass():
def __init__(self) -> None:
self.PropertyChanged += onPropertyChanged
@property
@default(10)
def exampleProperty(self) -> int: ...
@exampleProperty.setter
def exampleProperty(self,value) -> None: ...
Metadata
Release files for pyDictStore 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyDictStore-1.0.4.tar.gz | 4.9 kB | Without provenance | Details for pyDictStore-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyDictStore-1.0.4-py3-none-any.whl | Python 3 | none | any | Details for pyDictStore-1.0.4-py3-none-any.whl |
Total release size: 9.9 kB
Release files / pyDictStore-1.0.4.tar.gz
| Download URL | pyDictStore-1.0.4.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82ea5116b271ad7c2cb25566125b56c438a9c7eeb702d9da0c5aebea696a7d5e
|
|
BLAKE2b-256 checksum How to use checksums |
ab9722886eb18d95d16c1ae9761530a5e25df04c6ed4310c53e4a96df04a7fa0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.11
|
Release files / pyDictStore-1.0.4-py3-none-any.whl
| Download URL | pyDictStore-1.0.4-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ec4b686edefa443322ed50a3e1c261967c8cfdb5a539f7d7549a843bb1eebc7
|
|
BLAKE2b-256 checksum How to use checksums |
a23475229f8db389493fe56888df6ce765a39e84900c765cb6fd7b22b268d299
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.11
|
Security for pyDictStore 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.