#!c:\Program Files\Python39\python.exe # -*- coding: UTF-8 -*- ''' $RCSfile: dbconnection.py,v $ $Revision$ $Author: markus $ $Date$ The BioCASE querytool ''' import os, sys, logging # ***** include the biocase.lib directory in the python sys path for importing ***** exec(open(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, 'lib', 'biocase', 'adjustpath.py'))).read()) exec(open(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, 'lib', 'biocase', 'appinit.py'))).read()) from biocase.configtool.general import authorize, form, dsa, templateDir, dsaObj, log, getDropDownOptionHtml, printOverHTTP from biocase.tools.templating import PageMacro from biocase import __version__ ############################################################################################################ # # MAIN # #=========================================================================================================== # check authentication! if dsa is None: exec(compile(open( os.path.abspath( os.path.join( os.path.dirname( __file__ ), 'main.cgi' ) ), "rb").read(), os.path.abspath( os.path.join( os.path.dirname( __file__ ), 'main.cgi' ) ), 'exec')) sys.exit() # check authentication! authorize(form, dsa=dsa) # load html template tmpl = PageMacro('Content', PageMacro.DELMODE) tmpl.load('Content', os.path.join(templateDir, '_dbsettings.html')) # # get psfObj # psfObj = dsaObj.getPSFObj(tmp=False) # # look for new form values # if 'action' in form: psfObj.adminpassword = form.getfirst('adminpassword', None) try: psfObj.recLimit = int(form.getfirst('resultlimit', None)) except: log.debug( "REC LIMIT IS NO INTEGER") try: psfObj.archive_expiration = int(form.getfirst('expiration', None)) except: log.debug("ARCHIVE EXPIRATION PERIOD IS NO INTEGER") psfObj.loglevel = form.getfirst('loglevel', logging.INFO) # write new PSFile psfObj.writePSFile() log.debug( "PSFile written") # # fill template # # general stuff tmpl['dsa'] = dsa tmpl['wrapper_url'] = dsaObj.getBioCASeAccessPoint() tmpl['ServiceTitle'] = 'BioCASe Provider Software %s' % __version__ # settings tmpl['adminpassword'] = psfObj.adminpassword tmpl['resultlimit'] = str(psfObj.recLimit) tmpl['expiration'] = str(psfObj.archive_expiration) tmpl['loglevel'] = getDropDownOptionHtml({"DEBUG":logging.DEBUG, "INFO":logging.INFO, "WARN":logging.WARN, "ERROR":logging.ERROR}, psfObj.loglevel, keysSorted=['DEBUG','INFO','WARN','ERROR']) # # print HTML ! # printOverHTTP( tmpl )