mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +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`
|
||||
|
||||
## Catch-all tagets
|
||||
default: cherrypy.config dirs template css docs
|
||||
default: cherrypy.config dirs template css docs dbs
|
||||
all: default
|
||||
|
||||
dbs: data/users.sqlite3
|
||||
|
||||
data/users.sqlite3: data/users.sqlite3.distrib
|
||||
cp data/users.sqlite3.distrib data/users.sqlite3
|
||||
|
||||
dirs:
|
||||
@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__))
|
||||
data_dir = os.path.join(file_root, "data")
|
||||
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")
|
||||
access_log_file = os.path.join(data_dir, "access.log")
|
||||
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
|
||||
from model import User
|
||||
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
|
||||
thing, we read from the disk as needed. Writes are immediate,
|
||||
though.
|
||||
|
||||
@ -4,8 +4,12 @@
|
||||
import os, sys
|
||||
#import logging
|
||||
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 cfg, plugin_mount
|
||||
import plugin_mount
|
||||
from util import *
|
||||
from logger import Logger
|
||||
#from modules.auth import AuthController, require, member_of, name_is
|
||||
@ -100,10 +104,11 @@ def setup():
|
||||
cfg.log = Logger()
|
||||
load_modules()
|
||||
cfg.html_root = Root()
|
||||
cfg.users = plugin_mount.UserStoreModule.get_plugins()[0]
|
||||
cfg.page_plugins = plugin_mount.PagePlugin.get_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()
|
||||
|
||||
def main():
|
||||
setup()
|
||||
cherrypy.quickstart(cfg.html_root, script_name='/', config="cherrypy.config")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user