The Bitsmiths core central business library that all other Bitsmiths Products are built upon.
Project description
BITSMITHS LIB
This is the base/core Bitsmiths python library upon which all other products are built upon. This library contains the most common base objects and patterns that we use for all our other projects.
This library contains both normal and async version of these common objects so that projects down the line can choose to implement whichever version the need.
Library Objects
These are the common objects in the library as well as a short description of their intended purpose.
Transactionable
Transactionable
is an interface class that allows derived objects to extend begin
, commit
, and rollback
methods. This object is intended to be used with database connections or any transactionable object. For example the
Audit Product extends this to do automatic record auditing on the commit()
method.
Note there is also an TransactionableAsync
object for async code.
AutoTransaction
The AutoTransaction
object is designed to be used with one or many Transactionable
objects. After a piece of
work is complete, one would perform a commit()
which would in turn commit
all the transactionable objects that
were instantiated. If an error occurs, or if you do not do a commit()
, this object will auto rollback all
the transactionable objects for you.
Note there is also an AutoTransactionAsync
object for async code.
Below is an example of intended use:
def save_bank_record(self, brec: tBank):
with AutoTransaction(self.database_connection) as at:
with BankManager(self.database_connection) as bm:
bm.save(brec)
at.commit()
Pod
The intended purpose of the Pod is to contain the shared/common business objects in a given product. By our design we always at least have the following public properties in a pod:
- dbcon : The active database connection that is ready for use
- cfg : A shared/common configuration dictionary
- log : The active logging logger object that is ready for use
- usr_id : The current business or systems user identifier string that is performing the current action/work
Think of a Pod as a context maanager that you inject into all your business code down the line. The Pod contains
everything your business code needs to do its job. You are encouraged to extend the Pod
object to have
any other common business properties your project requires. Note also see the Provider for dynamically creating
core business objects.
You will notice that the Pod
inherits from Transactionable
and it also automatically commits
and rollbacks
the
database connection if it used with AutoTransaction
.
Note there is also a PodAsync
object for async code.
Provider
The provider is designed to be an interface that you can override to create commonly used objects from sort of factory. It was originally a pattern we copied from C++, but it does have a place in Python frameworks if one embraces the pattern. We don't use it much, but there is nothing wrong with having it here.
Query Builder
The query_builder
object is just a common piece of code use to string together dynamic SQL. Its is meant to be
relatively SQL Injection safe, but use it responsibly.
Common
This is just a collection of commonly used functions that we use often in multiple different products.
Sentinel
This is process/thread server management tool. More to explain here in the future.
Change History
2.1.4
Type | Description |
---|---|
Bug | SentinelManager now raises notification for failed pluggins/threads correctly. |
2.1.3
Type | Description |
---|---|
Bug | Fixed a blatent bug in SentinelManager when handling SentinelThread objects ending. |
2.1.2
Type | Description |
---|---|
New | Custom notification method added to sentinel manager when a child process or pluggin ends. |
2.1.1
Type | Description |
---|---|
New | Added parameters to SentinelProcess so that it can swallow standard output from child processes. |
Bug | Fixed the python SentinelThread.py was still importing the old Common module from bs_lib instead of common . |
2.1.0
Type | Description |
---|---|
New | The project now has a dependency on PYPI mettle instead of a external shared link. |
2.0.0
Type | Description |
---|---|
New | Added async equivalent objects for Pod (APod) and Transactionable (ATrasactionable). |
New | Added async version of sql_run and sql_fetch to common. |
Breaking Change | Removed initialize and destroy method from Pod. |
Breaking Change | Snake cased the entire library in regards to methods and members. |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bitsmiths-lib-2.1.4.tar.gz
.
File metadata
- Download URL: bitsmiths-lib-2.1.4.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 636aeb5e14cc504f59a7be7cf44d38484274d4a482f45bf715ba6be6caa1fe08 |
|
MD5 | 592514feb3b2e8a75dc91e5a85a84015 |
|
BLAKE2b-256 | e35f165e21dbadae05ef1a35ebd09244b19959b85278d8538adc239dff090563 |
File details
Details for the file bitsmiths_lib-2.1.4-py3-none-any.whl
.
File metadata
- Download URL: bitsmiths_lib-2.1.4-py3-none-any.whl
- Upload date:
- Size: 33.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4882c0c7c9fa39ce92a97958c7a98e088f4fae55a613482b360de6aae01480e3 |
|
MD5 | bf37d2e900013df80b97d972a41add2b |
|
BLAKE2b-256 | 9252184d1ff57dd4342d7125bd260c18ff0afbdebdfb2ddc6a09f85265ed9377 |