mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
move to sqlite3 + json dict storage for users
This commit is contained in:
parent
1bfcb608de
commit
d082538aee
7
Makefile
7
Makefile
@ -8,9 +8,14 @@ COMPRESSED_CSS := $(patsubst %.css,%.tiny.css,$(CSS))
|
|||||||
PWD=`pwd`
|
PWD=`pwd`
|
||||||
|
|
||||||
## Catch-all tagets
|
## Catch-all tagets
|
||||||
default: cherrypy.config dirs template css docs
|
default: cherrypy.config dirs template css docs dbs
|
||||||
all: default
|
all: default
|
||||||
|
|
||||||
|
dbs: data/users.sqlite3
|
||||||
|
|
||||||
|
data/users.sqlite3: data/users.sqlite3.distrib
|
||||||
|
cp data/users.sqlite3.distrib data/users.sqlite3
|
||||||
|
|
||||||
dirs:
|
dirs:
|
||||||
@mkdir -p data/cherrypy_sessions
|
@mkdir -p data/cherrypy_sessions
|
||||||
|
|
||||||
|
|||||||
1
cfg.py
1
cfg.py
@ -4,6 +4,7 @@ import os
|
|||||||
file_root = os.path.dirname(os.path.realpath(__file__))
|
file_root = os.path.dirname(os.path.realpath(__file__))
|
||||||
data_dir = os.path.join(file_root, "data")
|
data_dir = os.path.join(file_root, "data")
|
||||||
store_file = os.path.join(data_dir, "store.sqlite3")
|
store_file = os.path.join(data_dir, "store.sqlite3")
|
||||||
|
user_db = os.path.join(data_dir, "users")
|
||||||
status_log_file = os.path.join(data_dir, "status.log")
|
status_log_file = os.path.join(data_dir, "status.log")
|
||||||
access_log_file = os.path.join(data_dir, "access.log")
|
access_log_file = os.path.join(data_dir, "access.log")
|
||||||
users_dir = os.path.join(data_dir, "users")
|
users_dir = os.path.join(data_dir, "users")
|
||||||
|
|||||||
BIN
data/users.sqlite3.distrib
Normal file
BIN
data/users.sqlite3.distrib
Normal file
Binary file not shown.
@ -4,8 +4,19 @@ import cherrypy
|
|||||||
import cfg
|
import cfg
|
||||||
from model import User
|
from model import User
|
||||||
from plugin_mount import UserStoreModule
|
from plugin_mount import UserStoreModule
|
||||||
|
from withsqlite.withsqlite import sqlite_db
|
||||||
|
|
||||||
class UserStore(UserStoreModule):
|
class UserStore(UserStoreModule, sqlite_db):
|
||||||
|
def __init__(self):
|
||||||
|
self.data_dir = cfg.users_dir
|
||||||
|
self.db_file = cfg.user_db
|
||||||
|
sqlite_db.__init__(self, self.db_file)
|
||||||
|
self.__enter__()
|
||||||
|
def close(self):
|
||||||
|
self.__exit__()
|
||||||
|
|
||||||
|
class UserStoreOld():
|
||||||
|
#class UserStore(UserStoreModule):
|
||||||
"""The user storage is on disk. Rather than slurp the entire
|
"""The user storage is on disk. Rather than slurp the entire
|
||||||
thing, we read from the disk as needed. Writes are immediate,
|
thing, we read from the disk as needed. Writes are immediate,
|
||||||
though.
|
though.
|
||||||
|
|||||||
@ -4,8 +4,12 @@
|
|||||||
import os, sys
|
import os, sys
|
||||||
#import logging
|
#import logging
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
import cfg
|
||||||
|
if not os.path.join(cfg.file_root, "vendor") in sys.path:
|
||||||
|
sys.path.append(os.path.join(cfg.file_root, "vendor"))
|
||||||
|
|
||||||
import cherrypy
|
import cherrypy
|
||||||
import cfg, plugin_mount
|
import plugin_mount
|
||||||
from util import *
|
from util import *
|
||||||
from logger import Logger
|
from logger import Logger
|
||||||
#from modules.auth import AuthController, require, member_of, name_is
|
#from modules.auth import AuthController, require, member_of, name_is
|
||||||
@ -100,10 +104,11 @@ def setup():
|
|||||||
cfg.log = Logger()
|
cfg.log = Logger()
|
||||||
load_modules()
|
load_modules()
|
||||||
cfg.html_root = Root()
|
cfg.html_root = Root()
|
||||||
|
cfg.users = plugin_mount.UserStoreModule.get_plugins()[0]
|
||||||
cfg.page_plugins = plugin_mount.PagePlugin.get_plugins()
|
cfg.page_plugins = plugin_mount.PagePlugin.get_plugins()
|
||||||
cfg.log("Loaded %d page plugins" % len(cfg.page_plugins))
|
cfg.log("Loaded %d page plugins" % len(cfg.page_plugins))
|
||||||
cfg.users = plugin_mount.UserStoreModule.get_plugins()[0]
|
|
||||||
cfg.forms = plugin_mount.FormPlugin.get_plugins()
|
cfg.forms = plugin_mount.FormPlugin.get_plugins()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
setup()
|
setup()
|
||||||
cherrypy.quickstart(cfg.html_root, script_name='/', config="cherrypy.config")
|
cherrypy.quickstart(cfg.html_root, script_name='/', config="cherrypy.config")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user