|
1 | 1 | from setuptools import setup |
2 | 2 |
|
3 | 3 |
|
4 | | -readme = """ |
5 | | -SUMMARY |
6 | | -------- |
7 | | -
|
8 | | -Flask\_replicated is a Flask extension, designed to work with |
9 | | -SqlAlchemy. It's purpose it to provide more or less automatic |
10 | | -master-slave replication. On each request, extension determines database |
11 | | -usage intention (to read or to write into a database). Then, it picks |
12 | | -right database url inside overriden db.get\_engine() whenever request |
13 | | -handler tries to access database. |
14 | | -
|
15 | | -INSTALLATION |
16 | | ------------- |
17 | | -
|
18 | | -1. Install flask\_replicated distribution using "python setup.py |
19 | | - install". |
20 | | -
|
21 | | -2. In flask app.config configure your database bindings a standard way: |
22 | | -
|
23 | | - :: |
24 | | -
|
25 | | - SQLALCHEMY_DATABASE_URI = '%(schema)s://%(user)s:%(password)s@%(master_host)s/%(database)s' |
26 | | - SQLALCHEMY_BINDS = { |
27 | | - 'master': SQLALCHEMY_DATABASE_URI, |
28 | | - 'slave': '%(schema)s://%(user)s:%(password)s@%(slave_host)s/%(database)s' |
29 | | - } |
30 | | -
|
31 | | -3. Register app extension: |
32 | | -
|
33 | | - :: |
34 | | -
|
35 | | - app = Flask(...) |
36 | | - ... |
37 | | - FlaskReplicated(app) |
38 | | -
|
39 | | -USAGE |
40 | | ------ |
41 | | -
|
42 | | -Flask\_replicated routes SQL queries into different databases based on |
43 | | -request method. If method is one of READONLY\_METHODS which are defined |
44 | | -as set(['GET', 'HEAD']) |
45 | | -
|
46 | | -While this is usually enough there are cases when DB access is not |
47 | | -controlled explicitly by your business logic. Good examples are implicit |
48 | | -creation of sessions on first access, writing some bookkeeping info, |
49 | | -implicit registration of a user account somewhere inside the system. |
50 | | -These things can happen at arbitrary moments of time, including during |
51 | | -GET requests. |
52 | | -
|
53 | | -To handle these situations wrap appropriate view function with |
54 | | -@flask\_replicated.changes\_database decorator. It will mark function to |
55 | | -always use master database url. |
56 | | -
|
57 | | -GET after POST |
58 | | -~~~~~~~~~~~~~~ |
59 | | -
|
60 | | -There is a special case that needs addressing when working with |
61 | | -asynchronous replication scheme. Replicas can lag behind a master |
62 | | -database on receiving updates. In practice this mean that after |
63 | | -submitting a POST form that redirects to a page with updated data this |
64 | | -page may be requested from a slave replica that wasn't updated yet. And |
65 | | -the user will have an impression that the submit didn't work. |
66 | | -""" |
| 4 | +with open('README.rst') as fp: |
| 5 | + readme = fp.read() |
67 | 6 |
|
68 | 7 |
|
69 | 8 | setup( |
|
86 | 25 | 'Programming Language :: Python :: 2', |
87 | 26 | 'Programming Language :: Python :: 2.6', |
88 | 27 | 'Programming Language :: Python :: 2.7', |
| 28 | + 'Programming Language :: Python :: 3', |
| 29 | + 'Programming Language :: Python :: 3.5', |
| 30 | + 'Programming Language :: Python :: 3.6', |
| 31 | + 'Programming Language :: Python :: 3.7', |
89 | 32 | ], |
90 | 33 | version='1.3', |
91 | 34 | py_modules=['flask_replicated'], |
|
0 commit comments