# -*- coding: utf-8 -*- """ main Instantiate the database connection, model database tables and configure the user interface. It is tune to only satisfy the need of the controller, function pair. Note: Expose to controllers several global variables: * app * auth * db * virtdb * directSvc They can be retrieved in module via the protocol "current". """ from _mydb import DBURIS from auth import configure_auth, USER from gluon import current from gluon.tools import PluginManager from model_app import App from model_core import Core from model_harvester import Harvester from model_report import Report from plugin_dbui import (configure_forms, configure_grids, Dbui) # ............................................................................ # # Connection to databases # try: mysql = DBURIS[request.application] db = DAL(mysql, lazy_tables=False, migrate_enabled=False, pool_size=10) except RuntimeError: raise HTTP(500, T("Can't access the MySQL database !!!")) virtdb = DAL(None) current.db = db current.virtdb = virtdb # ............................................................................ # # Authentication # auth = configure_auth(db, migrate_user=False) current.auth = auth # ............................................................................ # # Language # T.set_current_languages("en", "en-gb", "en-us") # mother tongue T.force("fr-fr") # user language T.lazy = False # immediate translation # ............................................................................ # # Plugin dbui configuration # Dbui.define_paths( app_css="static/my.css", app_lg="static/limbra/locale/limbra-lang-fr.js", app_libmin="static/limbra-min.js", app_script="static/app.js") # ............................................................................ # # Constants # ONE_HOUR = 3600000 # ............................................................................ # # Create the database models # App.define_tables(db, T) Core.define_tables(db, T) Harvester.define_tables(db, T) Report.define_tables(db, T) # ............................................................................ # # Configure the user interface # Dbui.initialise_ui() directSvc = Dbui.start_directSvc() # common configuration for forms and grids tables = ["application", "auth_group", "auth_membership", "auth_user", "authors_roles", "axes", "categories", "collaborations", "controllers", "countries", "harvesters", "graphs", "lists", "metrics", "my_authors", "organisation", "projects", "publications", "publishers", "renderers", "reports", "sections", "status", "teams"] # a user see the categories table but he/she can not modify it. if session.role == USER: tables.remove("categories") configure_forms(tables, plugins=["pFormToolTip"], width=350) configure_grids(tables, plugins=["pGridRowEditorConfirmDelete", "pGridRowEditorContextMenu", "pGridRowEditorDblClick", "pGridToolbar"])