a28c00e474
- The login views are in `gestion/` - The templates are under `gestion/templates/gestion/` - `cof/shared.py` moves to `gestion/` and is splitted into 3 files: - The auth backends are in `backends.py`. - The context_processor is in `context_processor.py` - The LOCK/UNLOCK functions remain in `shared.py`
27 lines
584 B
Python
27 lines
584 B
Python
"""
|
|
Locking/unlocking tools to prevent tables to be corrupted
|
|
"""
|
|
|
|
from django.db import connection
|
|
|
|
|
|
def lock_table(*models):
|
|
query = "LOCK TABLES "
|
|
for i, model in enumerate(models):
|
|
table = model._meta.db_table
|
|
if i > 0:
|
|
query += ", "
|
|
query += "%s WRITE" % table
|
|
cursor = connection.cursor()
|
|
cursor.execute(query)
|
|
row = cursor.fetchone()
|
|
return row
|
|
|
|
|
|
def unlock_tables(*models):
|
|
cursor = connection.cursor()
|
|
cursor.execute("UNLOCK TABLES")
|
|
row = cursor.fetchone()
|
|
return row
|
|
|
|
unlock_table = unlock_tables
|