[open-ils-commits] r296 - in servres/trunk/conifer: . custom syrup templates templates/admin templates/feeds (gfawcett)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Apr 6 21:42:24 EDT 2009


Author: gfawcett
Date: 2009-04-06 21:42:22 -0400 (Mon, 06 Apr 2009)
New Revision: 296

Modified:
   servres/trunk/conifer/custom/lib_integration.py
   servres/trunk/conifer/settings.py
   servres/trunk/conifer/syrup/urls.py
   servres/trunk/conifer/syrup/views.py
   servres/trunk/conifer/templates/admin/index.xhtml
   servres/trunk/conifer/templates/browse_index.xhtml
   servres/trunk/conifer/templates/course_detail.xhtml
   servres/trunk/conifer/templates/edit_course.xhtml
   servres/trunk/conifer/templates/edit_course_permissions.xhtml
   servres/trunk/conifer/templates/feeds/course_feed_index.xhtml
   servres/trunk/conifer/templates/item_heading_detail.xhtml
   servres/trunk/conifer/templates/item_relocate.xhtml
   servres/trunk/conifer/templates/master.xhtml
   servres/trunk/conifer/urls.py
Log:
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.


Modified: servres/trunk/conifer/custom/lib_integration.py
===================================================================
--- servres/trunk/conifer/custom/lib_integration.py	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/custom/lib_integration.py	2009-04-07 01:42:22 UTC (rev 296)
@@ -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.marcxml import marcxml_to_dictionary
 
 
- at caching('itemstatus', timeout=300)
+ at caching('patroninfo', timeout=300)
 @SIP
 def patron_info(conn, barcode):
     return conn.patron_info(barcode)

Modified: servres/trunk/conifer/settings.py
===================================================================
--- servres/trunk/conifer/settings.py	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/settings.py	2009-04-07 01:42:22 UTC (rev 296)
@@ -8,7 +8,7 @@
 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 @@
 # 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 at vv(tuvt2+yu2r-$dxs$s7=iqjz_s!&'
@@ -102,9 +102,9 @@
 AUTH_PROFILE_MODULE = 'syrup.UserProfile'
 
 
-AUTHENTICATION_BACKENDS = [
+AUTHENTICATION_BACKENDS = (
     'django.contrib.auth.backends.ModelBackend',
-]
+)
 
 
 # more on this later.
@@ -131,4 +131,6 @@
 except:
     pass
 
-CACHE_BACKEND = 'locmem:///'
+#CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
+#CACHE_BACKEND = 'db://test_cache_table'
+#CACHE_BACKEND = 'locmem:///'

Modified: servres/trunk/conifer/syrup/urls.py
===================================================================
--- servres/trunk/conifer/syrup/urls.py	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/syrup/urls.py	2009-04-07 01:42:22 UTC (rev 296)
@@ -16,7 +16,6 @@
     (r'^browse/(?P<browse_option>.*)/$', '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'),

Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/syrup/views.py	2009-04-07 01:42:22 UTC (rev 296)
@@ -22,7 +22,7 @@
 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 _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 @@
     return g.render('phys/mark_arrived_outcome.xhtml')
 
 
+def custom_500_handler(request):
+    cls, inst, tb = sys.exc_info()
+    msg = simple_message(_('Error: %s') % repr(inst),
+                         repr((request.__dict__, inst)))
+    return HttpResponse(msg._container, status=501)
 
-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)))
+def custom_400_handler(request):
+    msg = simple_message(_('Not found'), 
+                          _('The page you requested could not be found'))
+    return HttpResponse(msg._container, status=404)

Modified: servres/trunk/conifer/templates/admin/index.xhtml
===================================================================
--- servres/trunk/conifer/templates/admin/index.xhtml	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/templates/admin/index.xhtml	2009-04-07 01:42:22 UTC (rev 296)
@@ -11,7 +11,7 @@
 <body>
   <h1>${title}</h1>
   <ul>
-    <li><a href="/admin/">Django Administrative UI</a></li>
+    <li><a href="../djadmin/">Django Administrative UI</a></li>
   </ul>
 
   <ul>

Modified: servres/trunk/conifer/templates/browse_index.xhtml
===================================================================
--- servres/trunk/conifer/templates/browse_index.xhtml	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/templates/browse_index.xhtml	2009-04-07 01:42:22 UTC (rev 296)
@@ -11,7 +11,7 @@
 <body>
   <h1>${title}</h1> 
   (Note: some course materials may require you
-    to <a href="/accounts/login/?next=/syrup/">log in</a>)
+    to <a href="/syrup/accounts/login/?next=/syrup/">log in</a>)
     <h2>Choose from one of the options below:</h2>
     <ul>
         <li><a href="courses">Browse by Course Name</a></li>

Modified: servres/trunk/conifer/templates/course_detail.xhtml
===================================================================
--- servres/trunk/conifer/templates/course_detail.xhtml	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/templates/course_detail.xhtml	2009-04-07 01:42:22 UTC (rev 296)
@@ -10,7 +10,7 @@
   <xi:include href="components/course.xhtml"/>
   <head>
     <title>${title}</title>
-    <script type="text/javascript" src="/static/menublocks.js"/>
+    <script type="text/javascript" src="/syrup/static/menublocks.js"/>
   </head>
   <body>
     ${course_banner(course)}

Modified: servres/trunk/conifer/templates/edit_course.xhtml
===================================================================
--- servres/trunk/conifer/templates/edit_course.xhtml	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/templates/edit_course.xhtml	2009-04-07 01:42:22 UTC (rev 296)
@@ -11,7 +11,7 @@
 <xi:include href="components/course.xhtml"/>
 <head>
   <title>${title}</title>
-  <script type="text/javascript" src="/static/edit_course.js"/>
+  <script type="text/javascript" src="/syrup/static/edit_course.js"/>
 </head>
 <body>
   <div py:if="instance.id">${course_banner(instance)}</div>

Modified: servres/trunk/conifer/templates/edit_course_permissions.xhtml
===================================================================
--- servres/trunk/conifer/templates/edit_course_permissions.xhtml	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/templates/edit_course_permissions.xhtml	2009-04-07 01:42:22 UTC (rev 296)
@@ -9,7 +9,7 @@
   <xi:include href="components/course.xhtml"/>
 <head>
   <title>${title}</title>
-  <script type="text/javascript" src="/static/edit_course_permissions.js"/>
+  <script type="text/javascript" src="/syrup/static/edit_course_permissions.js"/>
 </head>
 <body>
   ${course_banner(course)}

Modified: servres/trunk/conifer/templates/feeds/course_feed_index.xhtml
===================================================================
--- servres/trunk/conifer/templates/feeds/course_feed_index.xhtml	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/templates/feeds/course_feed_index.xhtml	2009-04-07 01:42:22 UTC (rev 296)
@@ -8,7 +8,7 @@
   <xi:include href="../components/course.xhtml"/>
   <head>
     <title>${title}</title>
-    <script type="text/javascript" src="/static/menublocks.js"/>
+    <script type="text/javascript" src="/syrup/static/menublocks.js"/>
   </head>
   <body>
     ${course_banner(course)}

Modified: servres/trunk/conifer/templates/item_heading_detail.xhtml
===================================================================
--- servres/trunk/conifer/templates/item_heading_detail.xhtml	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/templates/item_heading_detail.xhtml	2009-04-07 01:42:22 UTC (rev 296)
@@ -12,7 +12,7 @@
   <xi:include href="components/course.xhtml"/>
    <head>
     <title>${title}</title>
-    <script type="text/javascript" src="/static/menublocks.js"/>
+    <script type="text/javascript" src="/syrup/static/menublocks.js"/>
   </head>
   <body>
     ${course_banner(course)}

Modified: servres/trunk/conifer/templates/item_relocate.xhtml
===================================================================
--- servres/trunk/conifer/templates/item_relocate.xhtml	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/templates/item_relocate.xhtml	2009-04-07 01:42:22 UTC (rev 296)
@@ -8,7 +8,7 @@
   <xi:include href="components/course.xhtml"/>
    <head>
     <title>${title}</title>
-    <script type="text/javascript" src="/static/menublocks.js"/>
+    <script type="text/javascript" src="/syrup/static/menublocks.js"/>
   </head>
   <body>
     ${course_banner(course)}

Modified: servres/trunk/conifer/templates/master.xhtml
===================================================================
--- servres/trunk/conifer/templates/master.xhtml	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/templates/master.xhtml	2009-04-07 01:42:22 UTC (rev 296)
@@ -11,10 +11,10 @@
     <head py:attrs="select('@*')"
 	  py:with="t=list(select('title/text()'))">
       <title>${app_name}<py:if test="t">: ${t}</py:if></title>
-    <link rel="stylesheet" type="text/css" href="/static/main.css"/>
-    <script type="text/javascript" src="/static/jquery/js/jquery-1.3.2.min.js"/>
-    <script type="text/javascript" src="/static/jquery/js/jquery-ui-1.7.1.custom.min.js"/>
-    <script type="text/javascript" src="/static/jquery/js/jquery.tablesorter.min.js"/>
+    <link rel="stylesheet" type="text/css" href="/syrup/static/main.css"/>
+    <script type="text/javascript" src="/syrup/static/jquery/js/jquery-1.3.2.min.js"/>
+    <script type="text/javascript" src="/syrup/static/jquery/js/jquery-ui-1.7.1.custom.min.js"/>
+    <script type="text/javascript" src="/syrup/static/jquery/js/jquery.tablesorter.min.js"/>
     ${select('*[local-name()!="title"]')}
     </head>
   </py:match>
@@ -26,7 +26,7 @@
 	  ${os.getpid()}
 	  ${app_name}
 	</div>
-	<img src="/static/institution-logo.png" style="height: 50;"/>
+	<img src="/syrup/static/institution-logo.png" style="height: 50;"/>
       </div>
         <!--
       <div id="header" py:if="user.is_authenticated()">
@@ -44,12 +44,12 @@
         </div>
       <span py:if="user.is_authenticated()">
 	<strong style="padding-right: 18;">Welcome, ${user.first_name or user.username}!</strong>
-	<a href="/accounts/logout">Log Out</a>
+	<a href="/syrup/accounts/logout">Log Out</a>
 	&bull; <a href="/syrup/prefs/">Preferences</a>
       </span>
       <span py:if="not user.is_authenticated()">
 	<strong style="padding-right: 18;">Welcome!</strong>
-	<a class="loginbutton" href="/accounts/login/">Log In</a>
+	<a class="loginbutton" href="/syrup/accounts/login/">Log In</a>
 	&bull; <a href="/syrup/prefs/">Preferences</a>
       </span>
     </div>

Modified: servres/trunk/conifer/urls.py
===================================================================
--- servres/trunk/conifer/urls.py	2009-04-06 19:58:31 UTC (rev 295)
+++ servres/trunk/conifer/urls.py	2009-04-07 01:42:22 UTC (rev 296)
@@ -1,6 +1,13 @@
 from django.conf.urls.defaults import *
 from django.conf import settings
+import django
+import os
 
+# I know it's not recommended, but this lets us mount django-admin's
+# media through Django, through mod_python.
+
+ADMIN_MEDIA_ROOT = os.path.join(os.path.dirname(django.__file__), 'contrib/admin/media/')
+
 # Uncomment the next two lines to enable the admin:
 from django.contrib import admin
 admin.autodiscover()
@@ -11,19 +18,22 @@
 
     # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
     # to INSTALLED_APPS to enable admin documentation:
-    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
+    (r'^syrup/djadmin/doc/', include('django.contrib.admindocs.urls')),
 
     # Uncomment the next line to enable the admin:
-    (r'^admin/(.*)', admin.site.root),
-    (r'^syrup/', include('conifer.syrup.urls')),
-    (r'^static/(?P<path>.*)$', 'django.views.static.serve',
+    (r'^syrup/djadmin/(.*)', admin.site.root),
+    (r'^syrup/djmedia/(.*)', 'django.views.static.serve',
+        {'document_root': ADMIN_MEDIA_ROOT}),
+    (r'^syrup/static/(?P<path>.*)$', 'django.views.static.serve',
         {'document_root': settings.MEDIA_ROOT}),
-    (r'^accounts/(?P<path>.*)$', 'conifer.syrup.views.auth_handler'),
+    (r'^syrup/accounts/(?P<path>.*)$', 'conifer.syrup.views.auth_handler'),
 
 #    (r'^syrup/setlang', 'conifer.syrup.views.setlang'),
     (r'^syrup/i18n/', include('django.conf.urls.i18n')),
+    (r'^syrup/', include('conifer.syrup.urls')),
 
 )
 
 if not settings.DEBUG:
-    handler500 = 'conifer.syrup.views.custom_error_handler'
+    handler500 = 'conifer.syrup.views.custom_500_handler'
+    handler404b = 'conifer.syrup.views.custom_400_handler'



More information about the open-ils-commits mailing list