Commit 1ce16441 authored by gdetrez's avatar gdetrez

Encodage cass. a a l'air fix, mais je ne sais toujours pas vraiment d'o a vient...

darcs-hash:20070531090324-f46e9-60934f552dfa82357530d7ee093ac8ef1f614a14.gz
parent 678220f1
......@@ -29,6 +29,7 @@ import cherrypy, os, sys
make_path = os.path.join
import crans.utils.exceptions
from ClassesIntranet.AuthorisationsManager import setDroits
from crans.mail import quickSend
class Intranet:
# ######################################################## #
......@@ -43,28 +44,24 @@ class Intranet:
def loadModule(self, un_module):
MODULES_DIR = cherrypy.config.get("crans.modules.dir")
if not un_module.startswith("."):
if not (un_module.startswith(".") or un_module.startswith("_")):
# faire ici l'importation
# importer le fichier main.py
try:
#module_path = MODULES_DIR + un_module + "/main"
module_path = make_path(un_module, "main")
# import n'aime pas les chemins absolus !!
mon_module = __import__(module_path)
module_root = mon_module.main()
# on ajoute la classe a l'arborescence de cherrypy :
setattr( self, un_module, module_root)
# on ajoute le module aux modules connus :
try:
# on ajoute le module aux modules connus
cat = module_root.category()
if not self._loaded_modules.has_key(cat):
self._loaded_modules[cat] = {}
self._loaded_modules[cat] = {}
self._loaded_modules[cat][un_module] = module_root
except:
if cherrypy.config.get("server.environment") == "development":
_crans_cp.log("Impossible d'obtenir les parametres du module %s" % un_module)
_crans_cp.log(crans.utils.exceptions.formatExc())
# on ajoute les droits du module :
try:
# on ajoute les droits du module :
droits_module = module_root.droits()
setDroits("/%s" % un_module, droits_module)
except:
......@@ -202,7 +199,7 @@ Ceci est un rapport de bug envoye par l'intranet.
test.exposed = True
def _cp_on_http_error(self, status, message):
if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
if (cherrypy.config.configMap["global"]["server.environment"] == "development") or 1:
cherrypy._cputil._cp_on_http_error(status, message)
return
if status==403:
......@@ -220,7 +217,7 @@ Ceci est un rapport de bug envoye par l'intranet.
elif status==500:
self.send_error_repport(status = status, message = message )
# les filtres ne sont pas appliqués, on le fait à la main...
from plugins.templatesfilter import TemplatesFilter
from TemplatesManager import TemplatesFilter
TemplatesFilter().goWithThisDict({'template':'error', 'values':{'status':status, 'message':message }})
else:
self.send_error_repport(status = status, message = message)
......
......@@ -11,6 +11,7 @@ class ModuleBase:
_droits = []
_club = False
_adh = True
def droits(self):
return self._droits
......@@ -18,5 +19,8 @@ class ModuleBase:
if cherrypy.session['estClub'] == True:
if self._club == False:
return False
else:
if self._adh == False:
return False
return verifDroits(cherrypy.session['droits'], self.droits())
# -*- coding: utf-8 -*-
from cherrypy.filters.basefilter import BaseFilter
import cherrypy, os
from Cheetah.Template import Template
......@@ -84,7 +85,7 @@ class TemplatesFilter(BaseFilter):
except:
t = Template(file='main.tmpl', searchList=[body,{'login':''},values])
return str(t)
return t.__str__()
def goWithThisDict(self, aDict):
body = aDict
......@@ -93,13 +94,13 @@ class TemplatesFilter(BaseFilter):
templatevalues = self._getBodyNameSpace(body)
defaultvalues = {'static':self._getCorrectStaticMethod()}
t = Template(file=bodyTemplate, searchList=[templatevalues, defaultvalues])
body['page'] = str(t)
body['page'] = t.__str__()
if not self._isStandaloneBody(body):
body = self._useMainTemplate(body)
else:
body = body["page"]
cherrypy.response.body = body
cherrypy.response.body = body.encode("utf8")
def beforeFinalize(self):
......
......@@ -3,6 +3,6 @@ import cherrypy
def current_module():
current_path = cherrypy.request.object_path
module_name = current_path.split('/')[1]
if module_name != 'index':
if module_name not in ['index', 'send_error_repport']:
return module_name
return None
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# -*- coding: utf-8 -*-
# #############################################################
# ..
# .... ............ ........
......@@ -72,10 +72,11 @@ if (options.port):
# import du CransLdap qu'il va bien (on utilise CransLdap et non crans_ldap car on veut
# forcer l'ouverture d'une nouvelle connexion à chaque login)
if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
from ldap_crans_test import CransLdap
else:
from ldap_crans import CransLdap
#if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
# from ldap_crans_test import CransLdap
#else:
# from ldap_crans import CransLdap
from ldap_crans import CransLdap
sys.path.append(cherrypy.config.get('rootDir'))
# ######################################################## #
......
......@@ -78,7 +78,7 @@
<input type="text" id="login" name="login" value="$login" /><br />
<label class="textInputLabel" for="password">Password :</label>
<input type="password" id="password" name="password"/><br />
<input type="hidden" name="from_page" value="$from_page">
<input type="hidden" name="from_page" value="$from_page">
<div class="liens">
<input type="submit" value="Login" />
</div>
......
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