evolution, plus propre
darcs-hash:20061006190149-f46e9-26dccef11b6ed60711c19e004496559cba92e1bb.gz
This commit is contained in:
parent
3391f982b0
commit
892d69b876
1 changed files with 67 additions and 37 deletions
102
intranet/Root.py
102
intranet/Root.py
|
@ -5,6 +5,58 @@
|
||||||
import cherrypy, sys, os, datetime
|
import cherrypy, sys, os, datetime
|
||||||
sys.path.append('/usr/scripts/gestion/')
|
sys.path.append('/usr/scripts/gestion/')
|
||||||
|
|
||||||
|
|
||||||
|
# ######################################################## #
|
||||||
|
# COMMAND LINE OPTION #
|
||||||
|
# ######################################################## #
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
parser = OptionParser()
|
||||||
|
parser.add_option("-d", "--dev",
|
||||||
|
action="store_true", dest="dev", default=False,
|
||||||
|
help="launch in dev mode")
|
||||||
|
parser.add_option("-p", "--port",
|
||||||
|
action="store", type="int", dest="port",
|
||||||
|
help="change server port")
|
||||||
|
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
# ######################################################## #
|
||||||
|
# CONFIG #
|
||||||
|
# ######################################################## #
|
||||||
|
#
|
||||||
|
# mise en place de la conf
|
||||||
|
#
|
||||||
|
|
||||||
|
# on suppose qu'en version de developpement, le script est lance depuis le shell
|
||||||
|
if (options.dev):
|
||||||
|
cherrypy.config.update(file=os.getcwd() + "/conf/dev.cfg")
|
||||||
|
cherrypy.config.update(file=os.getcwd() + "/conf/intranet.cfg")
|
||||||
|
settings={'global': { 'rootDir': os.getcwd() } }
|
||||||
|
cherrypy.config.update(settings)
|
||||||
|
|
||||||
|
else:
|
||||||
|
cherrypy.config.update(file="/usr/scripts/intranet/conf/prod.cfg")
|
||||||
|
cherrypy.config.update(file="/usr/scripts/intranet/conf/intranet.cfg")
|
||||||
|
|
||||||
|
# changer le port ??
|
||||||
|
if (options.port):
|
||||||
|
settings={'global':{'server.socketPort':options.port}}
|
||||||
|
cherrypy.config.update(settings)
|
||||||
|
|
||||||
|
|
||||||
|
if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
|
||||||
|
from ldap_crans_test import crans_ldap
|
||||||
|
print("settings : unsing test ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
|
||||||
|
else:
|
||||||
|
from ldap_crans import crans_ldap
|
||||||
|
print("settings : unsing prod ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
|
||||||
|
cherrypy.config.update({'global':{'crans_ldap':crans_ldap()}})
|
||||||
|
|
||||||
# ######################################################## #
|
# ######################################################## #
|
||||||
# FILTRES MAISON #
|
# FILTRES MAISON #
|
||||||
# ######################################################## #
|
# ######################################################## #
|
||||||
|
@ -47,6 +99,14 @@ class Intranet:
|
||||||
}
|
}
|
||||||
info.exposed = True
|
info.exposed = True
|
||||||
|
|
||||||
|
'''
|
||||||
|
def _cp_on_http_error(self, status, message):
|
||||||
|
cherrypy.response.body = {
|
||||||
|
'template':'error',
|
||||||
|
'values':{'status':status, 'message':message },
|
||||||
|
'standalone':False,
|
||||||
|
}
|
||||||
|
'''
|
||||||
'''
|
'''
|
||||||
def nounous(self):
|
def nounous(self):
|
||||||
return "coucou"
|
return "coucou"
|
||||||
|
@ -99,51 +159,21 @@ def verifLogin(login = '', password = ''):
|
||||||
message = u"L'authentification a echoué."
|
message = u"L'authentification a echoué."
|
||||||
return message
|
return message
|
||||||
|
|
||||||
# ######################################################## #
|
|
||||||
# COMMAND LINE OPTION #
|
|
||||||
# ######################################################## #
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
from optparse import OptionParser
|
|
||||||
|
|
||||||
parser = OptionParser()
|
|
||||||
parser.add_option("-d", "--dev",
|
|
||||||
action="store_true", dest="dev", default=False,
|
|
||||||
help="launch in dev mode")
|
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
|
||||||
|
|
||||||
|
|
||||||
# ######################################################## #
|
|
||||||
# CHERRYPY #
|
|
||||||
# ######################################################## #
|
|
||||||
#
|
|
||||||
# mise en place de cherrypy + conf
|
|
||||||
#
|
|
||||||
|
|
||||||
cherrypy.config.update(file="/usr/scripts/intranet/conf/intranet.cfg")
|
|
||||||
if (options.dev):
|
|
||||||
cherrypy.config.update(file="/usr/scripts/intranet/conf/dev.cfg")
|
|
||||||
else:
|
|
||||||
cherrypy.config.update(file="/usr/scripts/intranet/conf/prod.cfg")
|
|
||||||
|
|
||||||
|
|
||||||
|
# on indique tout ca a cherrypy
|
||||||
settings={'/': {
|
settings={'/': {
|
||||||
'sessionAuthenticateFilter.checkLoginAndPassword': verifLogin,
|
'sessionAuthenticateFilter.checkLoginAndPassword': verifLogin,
|
||||||
'sessionAuthenticateFilter.loginScreen': login
|
'sessionAuthenticateFilter.loginScreen': login
|
||||||
}}
|
}}
|
||||||
cherrypy.config.update(settings)
|
cherrypy.config.update(settings)
|
||||||
|
|
||||||
if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
|
|
||||||
from ldap_crans_test import crans_ldap
|
|
||||||
print("settings : unsing test ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
|
# ######################################################## #
|
||||||
else:
|
# LANCEMENT DE CHERRYPY #
|
||||||
from ldap_crans import crans_ldap
|
# ######################################################## #
|
||||||
print("settings : unsing prod ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
|
|
||||||
cherrypy.config.update({'global':{'crans_ldap':crans_ldap()}})
|
|
||||||
cherrypy.root = Intranet()
|
cherrypy.root = Intranet()
|
||||||
|
|
||||||
cherrypy.server.start()
|
cherrypy.server.start()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue