You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traditionally, most web applications are written using MVC pattern. Python Business Logic helps you to add *Business Layer*, also called *Application Layer*, that is dependent only on models and composed of simple functions. Code written this way is extremely easy to read, test, and use in different scenarios. Package has no dependencies and can be used in any web framework, like Django, Flask, Bottle and others.
16
19
17
20
Documentation
18
21
-------------
19
22
20
-
The full documentation is at https://python-business-logic.readthedocs.io. (WIP)
23
+
The full documentation is at https://python-business-logic.readthedocs.io. Still under development.
21
24
22
25
Installation
23
26
------------
@@ -181,18 +184,23 @@ Usage
181
184
-----
182
185
183
186
When using this package, you should write all your business logic as simple functions, using only
184
-
inputs and Database Layer (for example, `Django ORM or SQLAlchemy`). This way, you can easily test your
187
+
inputs and Database Layer (eg. `Django ORM or SQLAlchemy`). This way, you can easily test your
185
188
logic and use it in any way you like. Convention that I follow is to put all functions inside `logic.py` file or `logic` submodule.
186
189
187
190
In **views** and **API** calls: Your role is to prepare all required data for business function (from forms, user session etc), call function
188
191
and present results to user. Middleware catching LogicException and, for example, displaying message to user in a generic way
189
192
can improve readability a lot, because no exception handling need to be done in view.
190
193
191
194
As **management commands**: In Django you can create custom `management command`, that allows you to use cli to perform custom logic.
192
-
Python Business Logic functions works very well with this use case!
195
+
Python Business Logic functions works very well for that use case!
193
196
194
197
From **external code**: Just import your function and use it. Since there shouldn't be any framework-related
195
-
inputs other than Database Models, usage is really simple. In reality, your business functions form **business API** of your application.
198
+
inputs other than Database Models, usage is really simple. In reality, your business functions form *business API* of your application.
199
+
200
+
Examples
201
+
--------
202
+
203
+
For examples how to use this library, look into directory *examples*. Currently there is only one called *Football match*. Most important file there is :code:`logic.py`.
0 commit comments