Exemplo n.º 1
0
    response.headers['Access-Control-Allow-Origin'] = request.env.http_origin
else:
    response.headers['Access-Control-Allow-Origin'] = "*"
response.headers['Access-Control-Allow-Credentials'] = 'true'
response.headers["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS"
response.headers['Access-Control-Max-Age'] = 86400

if request.env.request_method == 'OPTIONS':
    if request.env.http_access_control_request_method:
        response.headers[
            'Access-Control-Allow-Methods'] = request.env.http_access_control_request_method
        if request.env.http_access_control_request_headers:
            response.headers[
                'Access-Control-Allow-Headers'] = request.env.http_access_control_request_headers

ns = NervaStore(request, session, T, db)
npi = Npi(ns)
tool = NervaTools(ns)

service = Service()


def call():
    session.forget()
    return service()


def getVernum():
    return response.verNo

Exemplo n.º 2
0
  global response; response = globals.Response()
  import gluon.languages.translator as T
  from gluon.sql import DAL
  global db; db = DAL()
  from gluon.html import URL
  
from nerva2py.nervastore import NervaStore
from gluon.html import TABLE, TR, TD
from gluon.sqlhtml import SPAN, A

#postgres://username:password@localhost/database
#mysql://username:password@localhost/database
#sqlite://database.db

conStr="sqlite://demo.db"
ns = NervaStore(request, session, T, None)
ns.engine = "sqlite"
ns.connect.setConnect(uri=conStr, pool_size=0, createdb=False)
if ns.db:
  if not ns.store.defineTable(create=False):
    pass #"Error table define"
else:
  pass #"Could not connect to the database: "+conStr

response.generic_patterns = ['*'] if request.is_local else []

def login_validation(form):
  if form.vars.password=="":
    form.vars.password=None
  else:
    form.vars.password = ns.valid.get_md5_value(form.vars.password)
Exemplo n.º 3
0
def create_menu():
  ns_menu = []
  ns_menu.append((T('User Accounts'), False, URL("accounts"), []))
  ns_menu.append((T('Customer Databases'), False, URL("databases"), []))
  ns_menu_dbs = (T('Database Management'), False, None, [])
  ns_menu.append(ns_menu_dbs)
  ns_menu.append((T('Report templates'), False, URL("reports"), []))
  ns_menu.append((T('Server Settings'), False, URL("settings"), []))
  ns_menu.append((T('Change Password'), False, URL("change_password"), []))
  
  ns_menu_dbs[3].append((T('Database Creation'), False, URL("create_db"), []))
  ns_menu_dbs[3].append((T('Database Backup'), False, URL("create_backup"), []))
  ns_menu_dbs[3].append((T('Restore the Database'), False, URL("restore_backup"), []))
  return ns_menu

ns = NervaStore(request, session, T, db)
ui = AdminUi('nas_admin',request, session, db)
dbtool = DatabaseTools(ns); ntool = NervaTools(ns);
response.title=T('NAS ADMIN')
   
auth = response.auth = ui.connect.auth_ini(controller="nas",use_username=True,reset_password=False,register=True)
if db(db.auth_user.id > 0).count() > 0:
  auth.settings.actions_disabled.append('register')

response.ns_menu = create_menu()
ui.control.create_cmd(response,T,"b")

_editable =True
if session.auth:
  if session.auth.user.has_key("username"):
    if session.auth.user.username=="demo":
Exemplo n.º 4
0
    ns_menu_dbs = (T('Database Management'), False, None, [])
    ns_menu.append(ns_menu_dbs)
    ns_menu.append((T('Report templates'), False, URL("reports"), []))
    ns_menu.append((T('Server Settings'), False, URL("settings"), []))
    ns_menu.append((T('Change Password'), False, URL("change_password"), []))

    ns_menu_dbs[3].append(
        (T('Database Creation'), False, URL("create_db"), []))
    ns_menu_dbs[3].append(
        (T('Database Backup'), False, URL("create_backup"), []))
    ns_menu_dbs[3].append(
        (T('Restore the Database'), False, URL("restore_backup"), []))
    return ns_menu


ns = NervaStore(request, session, T, db)
ui = AdminUi('nas_admin', request, session, db)
dbtool = DatabaseTools(ns)
ntool = NervaTools(ns)
response.title = T('NAS ADMIN')

auth = response.auth = ui.connect.auth_ini(controller="nas",
                                           use_username=True,
                                           reset_password=False,
                                           register=True)
if db(db.auth_user.id > 0).count() > 0:
    auth.settings.actions_disabled.append('register')

response.ns_menu = create_menu()
ui.control.create_cmd(response, T, "b")