Commit 245cc93a authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the method Dbui.start_directSvc and remove models/plugin_dbui.py which not needed any more.

parent c23a298e
......@@ -31,6 +31,8 @@ dbui.Dbui.initialise(
# dbui_libmin="static/plugin_dbui/dbui-debug.js"
)
directSvc = dbui.Dbui.start_directSvc()
#.............................................................................
#
# CONSTANTS
......
""" plugin_dbui
Initialize the plugin_dbui
Define persistent storage, main services
and methods available on the client side.
"""
import plugin_dbui as dbui
# Start common services
dbSvc = dbui.DbSvc()
directSvc = dbui.DirectSvc()
# activate the debug mode
# this session variable is set by the control index or debug
dbSvc.debug = session.debug
directSvc.debug = session.debug
# register method available on the client side
@directSvc.register
def close_user_session():
return dbui.close_user_session()
@directSvc.register
def getForm(tablename):
return dbui.to_formPanel(db[tablename])
@directSvc.register
def getGrid(tablename):
return dbui.to_gridPanel(db[tablename])
@directSvc.register
def create(data):
return dbSvc.create(data)
@directSvc.register
def count(data):
return dbSvc.count(data)
@directSvc.register
def destroy(data):
return dbSvc.destroy(data)
@directSvc.register
def read(data):
return dbSvc.read(data)
@directSvc.register
def update(data):
return dbSvc.update(data)
......@@ -3,8 +3,10 @@
"""
import copy
import plugin_dbui as dbui
from gluon import current
from gluon.html import URL
from gluon.storage import Storage
from gluon.tools import PluginManager
......@@ -23,38 +25,38 @@ defaults = Storage(
app_script_dir=None,
# dbui library
dbui_conf=URL(c='plugin_dbui', f='dbui_conf'),
dbui_conf_debug=URL(c='plugin_dbui', f='dbui_conf', vars=dict(debug="")),
dbui_conf=URL(c="plugin_dbui", f="dbui_conf"),
dbui_conf_debug=URL(c="plugin_dbui", f="dbui_conf", vars=dict(debug="")),
dbui_css=[
'static/plugin_dbui/resources/css/kde-oxygen.css',
'static/plugin_dbui/resources/css/dbui.css'],
"static/plugin_dbui/resources/css/kde-oxygen.css",
"static/plugin_dbui/resources/css/dbui.css"],
dbui_debug='static/plugin_dbui/src/Dbui.js',
dbui_lg='static/plugin_dbui/locale/dbui-lang-%s.js',
dbui_libmin='static/plugin_dbui/dbui-min.js',
dbui_script='static/plugin_dbui/main.js',
dbui_debug="static/plugin_dbui/src/Dbui.js",
dbui_lg="static/plugin_dbui/locale/dbui-lang-%s.js",
dbui_libmin="static/plugin_dbui/dbui-min.js",
dbui_script="static/plugin_dbui/main.js",
# ACE library
ace_css='static/plugin_ace/css/editor.css',
ace_debug='static/plugin_ace/src-noconflict/ace.js',
ace_libmin='static/plugin_ace/src-min-noconflict/ace.js',
ace_css="static/plugin_ace/css/editor.css",
ace_debug="static/plugin_ace/src-noconflict/ace.js",
ace_libmin="static/plugin_ace/src-min-noconflict/ace.js",
# EXT JS library
extjs_css='static/plugin_extjs/build/classic/theme-classic/resources/theme-classic-all.css',
extjs_css="static/plugin_extjs/build/classic/theme-classic/resources/theme-classic-all.css",
extjs_debug=[
'static/plugin_extjs/build/ext-all-debug.js',
'static/plugin_extjs/build/classic/theme-classic/theme-classic-debug.js'],
"static/plugin_extjs/build/ext-all-debug.js",
"static/plugin_extjs/build/classic/theme-classic/theme-classic-debug.js"],
extjs_libmin=[
'static/plugin_extjs/build/ext-all.js',
'static/plugin_extjs/build/classic/theme-classic/theme-classic.js'],
"static/plugin_extjs/build/ext-all.js",
"static/plugin_extjs/build/classic/theme-classic/theme-classic.js"],
extjs_lg='static/plugin_extjs/build/classic/locale/locale-%s.js',
extjs_lg="static/plugin_extjs/build/classic/locale/locale-%s.js",
# MATHJAX library
mathjax_libmin='static/plugin_mathjax/MathJax.js')
mathjax_libmin="static/plugin_mathjax/MathJax.js")
class Dbui(object):
......@@ -72,6 +74,13 @@ class Dbui(object):
The persistent storage contains the configuration of the widgets
used in the user interface.
Note:
The configuration of the plugin is persistent across the
application. It can be accessed at any time using the syntax::
from gluon.tools import PluginManager
PluginManager("dbui").dbui
Args:
app_css (str or list):
......@@ -165,15 +174,6 @@ class Dbui(object):
Relative path to the minified version of the MathJax library:
``static/plugin_mathjax/MathJax.js``.
Returns:
gluons.storage.Storage:
the configuration parameters for the plugin dbui.
The configuration is persistent across the application.
It can be accessed at any time using the syntax::
from gluon.tools import PluginManager
PluginManager("dbui").dbui
"""
plugin = PluginManager("dbui").dbui
......@@ -196,3 +196,59 @@ class Dbui(object):
plugin.static_stores={}
return plugin
@staticmethod
def start_directSvc():
"""Start services to interact with the database from the
User Interface using the Ext JS Direct protocol.
Returns:
directSvc:
"""
db = current.globalenv["db"]
# Start common services
dbSvc = dbui.DbSvc()
directSvc = dbui.DirectSvc()
# activate the debug mode
# this session variable is set by the control index or debug
session = current.session
dbSvc.debug = session.debug
directSvc.debug = session.debug
# register method available on the client side
@directSvc.register
def close_user_session():
return dbui.close_user_session()
@directSvc.register
def getForm(tablename):
return dbui.to_formPanel(db[tablename])
@directSvc.register
def getGrid(tablename):
return dbui.to_gridPanel(db[tablename])
@directSvc.register
def create(data):
return dbSvc.create(data)
@directSvc.register
def count(data):
return dbSvc.count(data)
@directSvc.register
def destroy(data):
return dbSvc.destroy(data)
@directSvc.register
def read(data):
return dbSvc.read(data)
@directSvc.register
def update(data):
return dbSvc.update(data)
return directSvc
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment