def test(): set_context(True, creating=False) selected_dm(DB_PATH) from model import dm print(dm.get_user(1)) print(dm.get_user_id('demo', 'demo')) print(dm.get_client(1))
def uuid(id): set_context(True, creating=False) selected_dm(DB_PATH) from model import dm cl = dm.get_client(id) if cl: return cl.uuid else: return ''
def demo(): set_context(True, creating=False) selected_dm(DB_PATH) from model import dm a = dm.add_address(country='Poland') dm.add_user('demo', 'demo', name='John Down', email='*****@*****.**', address_id=a) dm.add_client('demoapp', 'secret', 1, 'http://127.0.0.1:3000')
def client(ident, secret, uri, user_id=1): set_context(True, creating=False) selected_dm(DB_PATH) from model import dm dm.add_client(ident, secret, user_id, uri)
def user(ident, secret, email): set_context(True, creating=False) selected_dm(DB_PATH) from model import dm dm.add_user(ident, secret, email=email)
def create(): set_context(True, creating=True) selected_dm(DB_PATH) from model import dm dm.create_db()
# coding: utf-8 # authors: Jerzy Wawro # (C) Galicea 2020 from model import selected_dm if selected_dm()=='sketch': from model import sketch as dm else: from model import dm def get_client(client_id): return dm.get_client(client_id) def get_client_by_uuid(uuid): return dm.get_client_by_uuid(uuid) #### int* / ext* def int_user_id(user_id): user=dm.get_user_by_login(user_id) return user.id if user else 0 def ext_user_id(user_id): user=dm.get_user(user_id) return user.login if user else None def int_client_id(client_id): if not client_id: return 0 app=dm.get_client_by_uuid(client_id) return app.id if app else 0