From f1ec50b0725ed9a656ace1e1df35cceee709ae0f Mon Sep 17 00:00:00 2001 From: gfawcett Date: Tue, 7 Apr 2009 01:42:22 +0000 Subject: [PATCH] for better mod_python deployment, moving all URLs under /syrup/ That will change next! I will move them all up to a relative root, and then Apache can decide what the root-prefix will be. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@296 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/custom/lib_integration.py | 14 ++++++++++---- conifer/settings.py | 12 +++++++----- conifer/syrup/urls.py | 1 - conifer/syrup/views.py | 18 +++++++++++------- conifer/templates/admin/index.xhtml | 2 +- conifer/templates/browse_index.xhtml | 2 +- conifer/templates/course_detail.xhtml | 2 +- conifer/templates/edit_course.xhtml | 2 +- conifer/templates/edit_course_permissions.xhtml | 2 +- conifer/templates/feeds/course_feed_index.xhtml | 2 +- conifer/templates/item_heading_detail.xhtml | 2 +- conifer/templates/item_relocate.xhtml | 2 +- conifer/templates/master.xhtml | 14 +++++++------- conifer/urls.py | 22 ++++++++++++++++------ 14 files changed, 59 insertions(+), 38 deletions(-) diff --git a/conifer/custom/lib_integration.py b/conifer/custom/lib_integration.py index 3b0c218..bf9bcb5 100644 --- a/conifer/custom/lib_integration.py +++ b/conifer/custom/lib_integration.py @@ -16,16 +16,22 @@ # define a @caching decorator to exploit the Django cache. Fixme, move # this somewhere else. from django.core.cache import cache +import cPickle def caching(prefix, timeout=60): def g(func): def f(*args): - v = cache.get((prefix, args)) + # wtf! Django encodes string-values as + # unicode-strings. That's bad, like stupid-bad! I'm + # putting explicit utf8-conversions here to make debugging + # easier if this code dies. + key = ','.join([prefix] + map(str, args)) + v = cache.get(key) if v: - return v + return cPickle.loads(v.encode('utf-8')) else: v = func(*args) if v: - cache.set((prefix, args), v, timeout) + cache.set(key, unicode(cPickle.dumps(v), 'utf-8'), timeout) return v return f return g @@ -41,7 +47,7 @@ from conifer.libsystems.z3950 import yaz_search from conifer.libsystems.z3950.marcxml import marcxml_to_dictionary -@caching('itemstatus', timeout=300) +@caching('patroninfo', timeout=300) @SIP def patron_info(conn, barcode): return conn.patron_info(barcode) diff --git a/conifer/settings.py b/conifer/settings.py index eb79a7e..41f00a3 100644 --- a/conifer/settings.py +++ b/conifer/settings.py @@ -8,7 +8,7 @@ import os BASE_DIRECTORY = os.path.abspath(os.path.dirname(__file__)) HERE = lambda s: os.path.join(BASE_DIRECTORY, s) -DEBUG = False +DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( @@ -59,7 +59,7 @@ MEDIA_URL = '' # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/", "/media/". -ADMIN_MEDIA_PREFIX = '/media/' +ADMIN_MEDIA_PREFIX = '/syrup/djmedia/' # Make this unique, and don't share it with anybody. SECRET_KEY = 'j$dnxqbi3iih+(@il3m@vv(tuvt2+yu2r-$dxs$s7=iqjz_s!&' @@ -102,9 +102,9 @@ INSTALLED_APPS = ( AUTH_PROFILE_MODULE = 'syrup.UserProfile' -AUTHENTICATION_BACKENDS = [ +AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', -] +) # more on this later. @@ -131,4 +131,6 @@ try: except: pass -CACHE_BACKEND = 'locmem:///' +#CACHE_BACKEND = 'memcached://127.0.0.1:11211/' +#CACHE_BACKEND = 'db://test_cache_table' +#CACHE_BACKEND = 'locmem:///' diff --git a/conifer/syrup/urls.py b/conifer/syrup/urls.py index 36b9170..0ad0ec0 100644 --- a/conifer/syrup/urls.py +++ b/conifer/syrup/urls.py @@ -16,7 +16,6 @@ urlpatterns = patterns('conifer.syrup.views', (r'^browse/(?P.*)/$', 'browse'), (r'^prefs/$', 'user_prefs'), (r'^z3950test/$', 'z3950_test'), - (r'^graham_z3950test/$', 'graham_z3950_test'), #MARK: propose we kill open_courses, we have browse. (r'^opencourse/$', 'open_courses'), (r'^search/$', 'search'), diff --git a/conifer/syrup/views.py b/conifer/syrup/views.py index c7d0949..d37a89d 100644 --- a/conifer/syrup/views.py +++ b/conifer/syrup/views.py @@ -22,7 +22,7 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User, SiteProfileNotAvailable from django.core.paginator import Paginator from django.db.models import Q -from django.http import HttpResponse, HttpResponseRedirect +from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound from django.http import HttpResponseForbidden from django.shortcuts import get_object_or_404 from django.utils import simplejson @@ -134,7 +134,7 @@ def _fast_user_membership_query(user_id, course_id, where=None): def _access_denied(request, message): if request.user.is_anonymous(): # then take them to login screen.... - dest = '/accounts/login/?next=' + request.environ['PATH_INFO'] + dest = '/syrup/accounts/login/?next=' + request.environ['PATH_INFO'] return HttpResponseRedirect(dest) else: return simple_message(_('Access denied.'), message, @@ -1379,9 +1379,13 @@ def phys_mark_arrived_match(request): return g.render('phys/mark_arrived_outcome.xhtml') - -def custom_error_handler(request): +def custom_500_handler(request): cls, inst, tb = sys.exc_info() - #fixme, set 50x code. - return simple_message(_('Error: %s') % repr(inst), - repr((request.__dict__, inst))) + msg = simple_message(_('Error: %s') % repr(inst), + repr((request.__dict__, inst))) + return HttpResponse(msg._container, status=501) + +def custom_400_handler(request): + msg = simple_message(_('Not found'), + _('The page you requested could not be found')) + return HttpResponse(msg._container, status=404) diff --git a/conifer/templates/admin/index.xhtml b/conifer/templates/admin/index.xhtml index ff7df8a..2c09a6e 100644 --- a/conifer/templates/admin/index.xhtml +++ b/conifer/templates/admin/index.xhtml @@ -11,7 +11,7 @@ title = _('Administrative Options')

${title}