From 1ad4a6fc4414abe477fbd3d368b94bfcec42fa05 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Mon, 6 Apr 2009 01:01:28 +0000 Subject: [PATCH] baby steps toward a good mod_python deployment. This works as is, with a overly-controlling Apache environment: SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE conifer.settings #PythonOption django.root /syrup PythonOption django.root PythonDebug Off PythonPath "['/home/graham/projects/evergreen/servres/'] + sys.path" git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@292 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/genshi_support.py | 2 +- conifer/libsystems/evergreen/support.py | 4 +++- conifer/settings.py | 6 ++++-- conifer/syrup/views.py | 6 ++++++ conifer/templates/master.xhtml | 2 ++ conifer/urls.py | 5 ++++- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/conifer/genshi_support.py b/conifer/genshi_support.py index 76d2fbb..54c9ec6 100644 --- a/conifer/genshi_support.py +++ b/conifer/genshi_support.py @@ -26,7 +26,7 @@ def template_loaded(template): template.filters.insert(0, Translator(_)) -dirs = ['templates'] +dirs = [settings.HERE('templates')] loader = TemplateLoader(dirs, auto_reload=True, callback=template_loaded) diff --git a/conifer/libsystems/evergreen/support.py b/conifer/libsystems/evergreen/support.py index 4e4454f..13459b8 100644 --- a/conifer/libsystems/evergreen/support.py +++ b/conifer/libsystems/evergreen/support.py @@ -4,7 +4,7 @@ from urllib import quote import simplejson as json from xml.etree import ElementTree import re -import sys +import sys, os #------------------------------------------------------------ # Configuration @@ -24,6 +24,8 @@ LOCALE = 'en-US' # FM_IDL_LOCATION = 'file:fm_IDL.xml' FM_IDL_LOCATION = 'http://dwarf.cs.uoguelph.ca/reports/fm_IDL.xml' +here = lambda s: os.path.join(os.path.dirname(__file__), s) +FM_IDL_LOCATION = 'file:' + here('fm_IDL.xml') #------------------------------------------------------------ # parse fm_IDL, to build a field-name-lookup service. diff --git a/conifer/settings.py b/conifer/settings.py index e3816e5..eb79a7e 100644 --- a/conifer/settings.py +++ b/conifer/settings.py @@ -5,10 +5,10 @@ import os -BASE_DIRECTORY = os.path.abspath(os.getcwd()) +BASE_DIRECTORY = os.path.abspath(os.path.dirname(__file__)) HERE = lambda s: os.path.join(BASE_DIRECTORY, s) -DEBUG = True +DEBUG = False TEMPLATE_DEBUG = DEBUG ADMINS = ( @@ -130,3 +130,5 @@ try: from private_local_settings import SIP_HOST, SIP_CREDENTIALS except: pass + +CACHE_BACKEND = 'locmem:///' diff --git a/conifer/syrup/views.py b/conifer/syrup/views.py index 892cc70..c7d0949 100644 --- a/conifer/syrup/views.py +++ b/conifer/syrup/views.py @@ -1379,3 +1379,9 @@ def phys_mark_arrived_match(request): return g.render('phys/mark_arrived_outcome.xhtml') + +def custom_error_handler(request): + cls, inst, tb = sys.exc_info() + #fixme, set 50x code. + return simple_message(_('Error: %s') % repr(inst), + repr((request.__dict__, inst))) diff --git a/conifer/templates/master.xhtml b/conifer/templates/master.xhtml index 48af57b..7a8cee5 100644 --- a/conifer/templates/master.xhtml +++ b/conifer/templates/master.xhtml @@ -1,6 +1,7 @@
+ ${os.getpid()} ${app_name}
diff --git a/conifer/urls.py b/conifer/urls.py index cbdf790..cf2d782 100644 --- a/conifer/urls.py +++ b/conifer/urls.py @@ -20,7 +20,10 @@ urlpatterns = patterns('', {'document_root': settings.MEDIA_ROOT}), (r'^accounts/(?P.*)$', 'conifer.syrup.views.auth_handler'), - (r'^syrup/setlang', 'conifer.syrup.views.setlang'), +# (r'^syrup/setlang', 'conifer.syrup.views.setlang'), (r'^syrup/i18n/', include('django.conf.urls.i18n')), ) + +if not settings.DEBUG: + handler500 = 'conifer.syrup.views.custom_error_handler' -- 2.11.0