[open-ils-commits] r8333 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb:
controllers lib templates/oils templates/oils/default
templates/oils/default/acq templates/oils/default/admin
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Jan 6 15:11:39 EST 2008
Author: erickson
Date: 2008-01-06 14:47:24 -0500 (Sun, 06 Jan 2008)
New Revision: 8333
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/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/lib/request.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/util.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/base.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/admin.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/base.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/index.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/rdetails.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/search.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/admin/object.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/base.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/dashboard.html
Log:
upated IDL calls to match new API. added better session data handling in the context object. changed block_title to page_title in templates since it is more of a page variable than a block of content
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/admin.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/admin.py 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/admin.py 2008-01-06 19:47:24 UTC (rev 8333)
@@ -21,39 +21,40 @@
class AdminController(BaseController):
- def init(self, type, id=None):
+ def init(self, obj_type, obj_id=None):
r = RequestMgr()
- r.ctx.adm.object_class = type
- meta = r.ctx.adm.object_meta = oils.utils.idl.oilsGetIDLParser().IDLObject[type]
+ r.ctx.adm.object_class = obj_type
+ meta = r.ctx.adm.object_meta = oils.utils.idl.IDLParser.get_class(obj_type)
- if id is not None:
+ if obj_id is not None:
r.ctx.adm.object = osrf.ses.AtomicRequest(
'open-ils.cstore',
'open-ils.cstore.direct.%s.retrieve' %
- meta['fieldmapper'].replace('::', '.'), id)
+ meta.fieldmapper.replace('::', '.'), obj_id)
return r
- def test(self, type, id):
- r = self.init()
- return r.render('dashboard.html')
+ def index(self):
+ r = RequestMgr()
+ return r.render('admin/index.html')
- def view(self, type, id):
- r = self.init(type, id)
+ def view(self, **kwargs):
+ r = self.init(kwargs['type'], kwargs['id'])
+ r.ctx.adm.mode = 'view'
return r.render('admin/object.html')
- def update(self, type, id):
- r = self.init(type, id)
- c.oils.adm.mode = 'update'
+ def update(self, **kwargs):
+ r = self.init(kwargs['type'], kwargs['id'])
+ r.ctx.adm.mode = 'update'
return r.render('admin/object.html')
- def create(self, type):
- r = self.init(type, id)
- c.oils.adm.mode = 'create'
+ def create(self, **kwargs):
+ r = self.init(kwargs['type'])
+ r.ctx.adm.mode = 'create'
return r.render('admin/object.html')
- def delete(self, type, id):
- r = self.init(type, id)
- c.oils.adm.mode = 'delete'
+ def delete(self, **kwargs):
+ r = self.init(kwargs['type'], kwargs['id'])
+ r.ctx.adm.mode = 'delete'
return r.render('admin/object.html')
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py 2008-01-06 19:47:24 UTC (rev 8333)
@@ -17,7 +17,7 @@
self.ac_prefix = ContextItem() # added content prefix
self.skin = ContextItem() # web skin
self.theme = ContextItem() # web theme
- self.authtoken = ContextItem(cgi_name='ses', cookie=True) # authtoken string
+ self.authtoken = ContextItem(cgi_name='ses', session=True) # authtoken string
self.user = ContextItem() # logged in user object
self.workstation = ContextItem() # workstation object
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/context.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/context.py 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/context.py 2008-01-06 19:47:24 UTC (rev 8333)
@@ -15,7 +15,7 @@
self.default_value = kwargs.get('default_value')
self.qname = None
self.multi = kwargs.get('multi')
- self.cookie = kwargs.get('cookie')
+ self.session = kwargs.get('session')
class SubContext(object):
''' A SubContext is a class-specific context object that lives inside the global context object '''
@@ -42,7 +42,7 @@
q = ''
for f in self._fields:
- if f.cgi_name and not f.cookie:
+ if f.cgi_name and not f.session:
val = getattr(getattr(self, f.app), f.name)
if val != f.default_value:
if isinstance(val, list):
@@ -55,12 +55,13 @@
return q[:-1] # strip the trailing &
- def apply_cookies(self):
+ def apply_session_vars(self):
+ from oilsweb.lib.base import session
for f in self._fields:
- if f.cgi_name and f.cookie:
+ if f.cgi_name and f.session:
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?
+ if val is not None and val != f.default_value:
+ session[f.cgi_name] = val
@staticmethod
@@ -76,6 +77,7 @@
@staticmethod
def init(req, resp):
global _context, _subContexts
+ from oilsweb.lib.base import session
c = _context = Context()
c._req = req
c._resp = resp
@@ -91,6 +93,11 @@
item.name = name
c._fields.append(item)
+ # -------------------------------------------------------------------
+ # Load the cgi/session data. First try the URL params, then try the
+ # session cache, and finally see if the data is in a cookie. If
+ # no data is found, use the default
+ # -------------------------------------------------------------------
set = False
if item.cgi_name:
if item.cgi_name in req.params:
@@ -100,9 +107,14 @@
setattr(getattr(c, app), name, req.params[item.cgi_name])
set = True
else:
- if item.cookie and item.cgi_name in req.cookies:
- setattr(getattr(c, app), name, req.cookies[item.cgi_name])
- set = True
+ if item.session:
+ if item.cgi_name in session:
+ setattr(getattr(c, app), name, session[item.cgi_name])
+ set = True
+ else:
+ if 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)
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/request.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/request.py 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/request.py 2008-01-06 19:47:24 UTC (rev 8333)
@@ -25,8 +25,8 @@
def finalize(self):
''' Perform any last minute cleanup just prior to sending the result '''
if not self.finalized:
+ self.ctx.apply_session_vars()
self.session.save()
- self.ctx.apply_cookies()
self.pylons_context.oils = self.ctx
self.finalized = True
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/util.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/util.py 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/util.py 2008-01-06 19:47:24 UTC (rev 8333)
@@ -1,27 +1,18 @@
import pylons.config, pylons.templating
import libxml2, libxslt
-import oils.utils.utils
+#import oils.utils.utils
def childInit():
''' Global child-init handler.
- 1. Connects to the OpenSRF network. Note that the OpenSRF
- layer ensures that there is only one connection per thread.
- 2. Parses the IDL file '''
- import osrf.system, osrf.set, oils.utils.idl, oils.utils.csedit, osrf.cache
- osrf.system.connect(pylons.config['osrf_config'], pylons.config['osrf_config_ctxt'])
- oils.utils.idl.oilsParseIDL()
- oils.utils.csedit.oilsLoadCSEditor()
+ 1. Connects to the OpenSRF network.
+ 2. Parses the IDL file
+ '''
- # live in opensrf somewhere
- servers = osrf.set.get('cache.global.servers.server')
- if not isinstance(servers, list):
- servers = [servers]
- if not osrf.cache.CacheClient.get_client():
- osrf.cache.CacheClient.connect(servers)
+ import oils.system, osrf.system
+ oils.system.oilsConnect(pylons.config['osrf_config'], pylons.config['osrf_config_ctxt'])
+ osrf.system.connect_cache()
-
-
_parsedSheets = {}
def apply_xsl(xmlStr, xslFile, xslParams={}):
doc = libxml2.parseDoc(xmlStr)
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/base.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/base.html 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/base.html 2008-01-06 19:47:24 UTC (rev 8333)
@@ -11,8 +11,8 @@
<%def name='block_head()'> <!-- haha.. blockhead -->
<!-- Construct a sane default HTML head -->
<head>
- <%def name="block_title()">${_('Evergreen Acquisitions')}</%def>
- <title>${self.block_title()}</title>
+ <%def name="page_title()">${_('Evergreen Acquisitions')}</%def>
+ <title>${self.page_title()}</title>
${self.block_css()}
</head>
</%def>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/admin.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/admin.html 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/admin.html 2008-01-06 19:47:24 UTC (rev 8333)
@@ -1,5 +1,5 @@
<%inherit file='../base.html'/>
-<%def name="block_title()">${_('Evergreen Acquisitions Administration ')}</%def>
+<%def name="page_title()">${_('Evergreen Acquisitions Administration ')}</%def>
<%def name="block_content()">
<h1>${_('Evergreen Acquisitions Administration ')}</h1>
<pre>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/base.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/base.html 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/base.html 2008-01-06 19:47:24 UTC (rev 8333)
@@ -2,3 +2,4 @@
<%def name="block_sub_navigate()">
<%include file='navigate.html'/>
</%def>
+
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/index.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/index.html 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/index.html 2008-01-06 19:47:24 UTC (rev 8333)
@@ -1,6 +1,6 @@
<%inherit file='base.html'/>
-<%def name="block_title()">${_('Evergreen Acquisitions Home')}</%def>
+<%def name="page_title()">${_('Evergreen Acquisitions Home')}</%def>
<%def name="block_content()">
<div id='oils-acq-index-block'>
ACQ HOME
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist.html 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist.html 2008-01-06 19:47:24 UTC (rev 8333)
@@ -1,5 +1,5 @@
<%inherit file='base.html'/>
-<%def name="block_title()">${_('Evergreen ACQ Picklist')}</%def>
+<%def name="page_title()">${_('Evergreen ACQ Picklist')}</%def>
<%def name="block_content()">
<table id='oils-acq-picklist-table'>
% for rec in c.oils_acq_records:
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html 2008-01-06 19:47:24 UTC (rev 8333)
@@ -1,5 +1,5 @@
<%inherit file='base.html'/>
-<%def name="block_title()">${_('Evergreen Acquisitions Results')}</%def>
+<%def name="page_title()">${_('Evergreen Acquisitions Results')}</%def>
<%def name="block_content()">
<form action='create_picklist' method='GET'>
<input type='hidden' name='${c.oils.acq.search_cache_key_.cgi_name}' value='${c.oils.acq.search_cache_key}'/>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/rdetails.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/rdetails.html 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/rdetails.html 2008-01-06 19:47:24 UTC (rev 8333)
@@ -1,5 +1,5 @@
<%inherit file='base.html'/>
-<%def name="block_title()">${_('Evergreen ACQ Details')}</%def>
+<%def name="page_title()">${_('Evergreen ACQ Details')}</%def>
<%def name="block_content()">
<div class='label'>Summary</div>
<div id='oils-acq-rdetail-summary-block'>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/search.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/search.html 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/search.html 2008-01-06 19:47:24 UTC (rev 8333)
@@ -1,5 +1,5 @@
<%inherit file='base.html'/>
-<%def name="block_title()">${_('Evergreen Acquisitions Search')}</%def>
+<%def name="page_title()">${_('Evergreen Acquisitions Search')}</%def>
<%def name="block_content()">
<form method='GET' action='pl_builder'>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/admin/object.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/admin/object.html 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/admin/object.html 2008-01-06 19:47:24 UTC (rev 8333)
@@ -1,8 +1,10 @@
+<!-- vim:set filetype=mako: -->
<%inherit file='base.html'/>
+<%namespace name='widget' file='widgets.html'/>
-<%def name="block_title()">${_('Evergreen Admin')}</%def>
+<%def name="page_title()">${_('Evergreen Admin')}</%def>
<%def name="block_content()">
- <div id='oils-admin-object-lable'>${c.oils.adm.object_meta['rpt_label']}</div>
+ <div id='oils-admin-object-lable'>${c.oils.adm.object_meta.label}</div>
% if c.oils.adm.mode == 'delete':
<div>
<%
@@ -12,19 +14,21 @@
${string}
</div>
% else:
+ <form action='update_object' method='POST'>
<table id='oils-admin-object-table'>
- % for fieldmeta in [ f for f in c.oils.adm.object_meta['fields'] if not f['virtual']]:
+ % for fieldmeta in [ f for f in c.oils.adm.object_meta.fields if not f.virtual]:
<tr>
- <td>${fieldmeta['rpt_label']}</td>
+ <td>${fieldmeta.label}</td>
<td>
% if c.oils.adm.mode == 'update':
- <input type='text' size='36' value='${unicode(getattr(c.oils.adm.object, fieldmeta["name"])())}'/>
+ (${fieldmeta.rpt_datatype})
+ ${widget.load(fieldmeta.rpt_datatype,fieldmeta.name, getattr(c.oils.adm.object, fieldmeta.name)())}
% else:
% if c.oils.adm.mode == 'create':
<input type='text'size='36' />
% else:
% if c.oils.adm.mode == 'view':
- <span>${unicode(getattr(c.oils.adm.object, fieldmeta['name'])())}</span>
+ <span>${unicode(getattr(c.oils.adm.object, fieldmeta.name)())}</span>
% endif
% endif
% endif
@@ -32,6 +36,7 @@
</tr>
% endfor
</table>
+ </form>
% endif
</%def>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/base.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/base.html 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/base.html 2008-01-06 19:47:24 UTC (rev 8333)
@@ -33,10 +33,10 @@
${self.block_content()}
</%def>
<%def name='block_content()'/>
+<%def name='block_sub_navigate()'/>
<%def name='block_navigate()'>
<%include file='navigate.html'/>
</%def>
<%def name='block_footer()'>
<%include file='footer.html'/>
</%def>
-<%def name='block_sub_navigate()'/>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/dashboard.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/dashboard.html 2008-01-06 19:43:02 UTC (rev 8332)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/dashboard.html 2008-01-06 19:47:24 UTC (rev 8333)
@@ -1,6 +1,6 @@
<%inherit file='base.html'/>
-<%def name="block_title()">${_('Evergreen Dashboard')}</%def>
+<%def name="page_title()">${_('Evergreen Dashboard')}</%def>
<%def name="block_content()">
<div id='oils-dashboard-block'>
DASHBOARD
More information about the open-ils-commits
mailing list