[open-ils-commits] r8279 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb:
controllers lib public/oils/media/css/skin
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Dec 26 17:12:11 EST 2007
Author: erickson
Date: 2007-12-26 16:49:32 -0500 (Wed, 26 Dec 2007)
New Revision: 8279
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/context.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/acq_default.css
Log:
added ability to store and retrieve context objects as cookies in addition to url params. added AuthException objects when no valid authtoken (user + workstation) is found
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py 2007-12-26 17:23:44 UTC (rev 8278)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq.py 2007-12-26 21:49:32 UTC (rev 8279)
@@ -1,7 +1,6 @@
from oilsweb.lib.base import *
import logging
-import pylons
import oilsweb.lib.context
import oilsweb.lib.util
import oilsweb.lib.acq.search
@@ -29,11 +28,11 @@
class AcqController(BaseController):
def index(self):
- c.oils = oilsweb.lib.context.Context.init(request)
+ c.oils = oilsweb.lib.context.Context.init(request, response)
return render('oils/%s/acq/index.html' % c.oils.core.skin)
def search(self):
- c.oils = Context.init(request)
+ c.oils = Context.init(request, response)
c.oils_z39_sources = oilsweb.lib.acq.search.fetch_z39_sources(c.oils)
sc = {}
@@ -49,7 +48,7 @@
def pl_builder(self):
- ctx = oilsweb.lib.context.Context.init(request)
+ ctx = oilsweb.lib.context.Context.init(request, response)
# add logic to see where we are fetching bib data from
if ctx.acq.search_source:
@@ -81,7 +80,7 @@
return oilsweb.lib.acq.search.multi_search(ctx, search)
def rdetails(self):
- c.oils = oilsweb.lib.context.Context.init(request)
+ c.oils = oilsweb.lib.context.Context.init(request, response)
rec_id = c.oils.acq.record_id
cache_key = c.oils.acq.search_cache_key
@@ -95,7 +94,7 @@
def create_picklist(self):
- ctx = oilsweb.lib.context.Context.init(request)
+ ctx = oilsweb.lib.context.Context.init(request, response)
if not isinstance(ctx.acq.picklist_item, list):
ctx.acq.picklist_item = [ctx.acq.picklist_item]
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py 2007-12-26 17:23:44 UTC (rev 8278)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py 2007-12-26 21:49:32 UTC (rev 8279)
@@ -31,7 +31,7 @@
import pprint
# Parse IDL and render as links for viewing the objects, perhaps?
- c.oils = oilsweb.lib.context.Context.init(request)
+ c.oils = oilsweb.lib.context.Context.init(request, response)
c.request = request
oilsConnect('/openils/conf/opensrf_core.xml', 'config.opensrf')
c.idl = oils.utils.idl.oilsGetIDLParser()
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py 2007-12-26 17:23:44 UTC (rev 8278)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py 2007-12-26 21:49:32 UTC (rev 8279)
@@ -1,14 +1,23 @@
from oilsweb.lib.context import Context, SubContext, ContextItem
import osrf.ses, oils.utils.csedit, pylons.config
+from gettext import gettext as _
+class AuthException(Exception):
+ def __init__(self, info=''):
+ self.info = info
+ def __str__(self):
+ return "%s: %s" % (self.__class__.__name__, unicode(self.info))
+
+
+
class CoreContext(SubContext):
def __init__(self):
- self.prefix = ContextItem() # web prefi
+ self.prefix = ContextItem() # web prefix
self.media_prefix = ContextItem() # media prefix
self.ac_prefix = ContextItem() # added content prefix
self.skin = ContextItem() # web skin
self.theme = ContextItem() # web theme
- self.authtoken = ContextItem(cgi_name='ses') # authtoken string
+ self.authtoken = ContextItem(cgi_name='ses', cookie=True) # authtoken string
self.user = ContextItem() # logged in user object
self.workstation = ContextItem() # workstation object
@@ -36,8 +45,14 @@
self.user = osrf.ses.AtomicRequest(
'open-ils.auth',
'open-ils.auth.session.retrieve', self.authtoken)
+
+ if not self.user:
+ raise AuthException(_('No user found with authtoken %(self.authtoken)s'))
self.workstation = oils.utils.csedit.CSEditor().retrieve_actor_workstation(self.user.wsid())
+ if not self.workstation:
+ raise AuthException(_('No workstation found'))
+
# cache the auth data and destroy any old auth data
CoreContext._auth_cache = {
self.authtoken : {
@@ -45,6 +60,8 @@
'workstation' : self.workstation
}
}
+ else:
+ raise AuthException(_('No authentication token provided'))
Context.applySubContext('core', CoreContext)
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/context.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/context.py 2007-12-26 17:23:44 UTC (rev 8278)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/context.py 2007-12-26 21:49:32 UTC (rev 8279)
@@ -13,6 +13,7 @@
self.default_value = kwargs.get('default_value')
self.qname = None
self.multi = kwargs.get('multi')
+ self.cookie = kwargs.get('cookie')
class SubContext(object):
''' A SubContext is a class-specific context object that lives inside the global context object '''
@@ -30,6 +31,8 @@
def __init__(self):
self._fields = []
+ self._req = None
+ self._resp = None
def make_query_string(self):
''' Compiles a CGI query string from the collection of values
@@ -37,7 +40,7 @@
q = ''
for f in self._fields:
- if f.cgi_name:
+ if f.cgi_name and not f.cookie:
val = getattr(getattr(self, f.app), f.name)
if val != f.default_value:
if isinstance(val, list):
@@ -53,6 +56,14 @@
return q
+ def apply_cookies(self):
+ for f in self._fields:
+ if f.cgi_name and f.cookie:
+ val = getattr(getattr(self, f.app), f.name)
+ if isinstance(val, str) or isinstance(val, unicode):
+ self._resp.set_cookie(f.cgi_name, val) # config var for timeout?
+
+
@staticmethod
def applySubContext(app, ctx):
global _subContexts
@@ -64,25 +75,37 @@
return _context
@staticmethod
- def init(req):
+ def init(req, resp):
global _context, _subContexts
c = _context = Context()
+ c._req = req
+ c._resp = resp
childInit()
for app, ctx in _subContexts.iteritems():
ctx = ctx()
setattr(c, app, ctx)
for name in ctx._fields():
+
item = getattr(ctx, name)
item.app = app
item.name = name
c._fields.append(item)
- if item.cgi_name and item.cgi_name in req.params:
- if item.multi:
- setattr(getattr(c, app), name, req.params.getall(item.cgi_name))
+
+ set = False
+ if item.cgi_name:
+ if item.cgi_name in req.params:
+ if item.multi:
+ setattr(getattr(c, app), name, req.params.getall(item.cgi_name))
+ else:
+ setattr(getattr(c, app), name, req.params[item.cgi_name])
+ set = True
else:
- setattr(getattr(c, app), name, req.params[item.cgi_name])
- else:
+ if item.cookie and item.cgi_name in req.cookies:
+ setattr(getattr(c, app), name, req.cookies[item.cgi_name])
+ set = True
+
+ if not set:
setattr(getattr(c, app), name, item.default_value)
# store the metatdata at <name>_
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/acq_default.css
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/acq_default.css 2007-12-26 17:23:44 UTC (rev 8278)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/acq_default.css 2007-12-26 21:49:32 UTC (rev 8279)
@@ -1,5 +1,7 @@
#oils-acq-index-block { font-weight:bold; }
+
+/* bib search */
#oils-acq-search-container { width:100%; }
#oils-acq-search-sources-block { width:32%; vertical-align: top; float: left; margin-right: 10px;}
#oils-acq-search-form-block { width:63%; vertical-align: top; float:right; }
@@ -8,7 +10,6 @@
.oils-acq-search-form-row { width: 100%; }
.oils-acq-search-form-label {}
.oils-acq-search-form-input {}
-
#oils-acq-search-sources-list { padding: 1px; }
#oils-acq-search-sources-list li { list-style-type: none; padding-left: 0px; }
.oils-acq-search-sources-sublist { padding: 1px; list-style-type: none;}
@@ -18,6 +19,7 @@
#oils-acq-search-fields-label { margin-bottom: 10px; }
#oils-acq-search-fields-submit-block { margin: 5px; text-align: center;}
+/* bib search results / picklist builder interface */
#oils-acq-pl_builder-table { width: 100%; }
.oils-acq-record_list-records-jacket { width: 42px; height: 54px; padding-left: 10px; }
.oils-acq-record_list-records-title-row {}
@@ -28,3 +30,5 @@
#oils-acq-picklist-table { width: 100%; }
+
+
More information about the open-ils-commits
mailing list