[open-ils-commits] r8273 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb: config
controllers templates/oils/default/acq
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Dec 21 15:43:14 EST 2007
Author: dbs
Date: 2007-12-21 15:21:19 -0500 (Fri, 21 Dec 2007)
New Revision: 8273
Added:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/admin.html
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/config/routing.py
Log:
Ugly text dump of registry objects and exposed CSEditor methods
Adds new route at http://hostname:5000/acq/admin
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/config/routing.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/config/routing.py 2007-12-21 18:42:39 UTC (rev 8272)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/config/routing.py 2007-12-21 20:21:19 UTC (rev 8273)
@@ -19,7 +19,9 @@
# CUSTOM ROUTES HERE
map.connect('oils/:controller/:action')
- #map.connect(':controller/:action/:id')
+ map.connect('acq_admin', 'oils/admin', controller='acq_admin')
+ map.connect('acq_admin_object', 'oils/admin/:object', controller='acq_admin')
+ map.connect('acq_admin_direct', 'oils/admin/direct/:object/:id', controller='acq_admin')
map.connect('*url', controller='template', action='view')
return map
Added: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py (rev 0)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py 2007-12-21 20:21:19 UTC (rev 8273)
@@ -0,0 +1,41 @@
+import logging
+
+from oilsweb.lib.base import *
+import pylons, os
+import oilsweb.lib.context
+import oilsweb.lib.util
+import oilsweb.lib.acq.search
+from oilsweb.lib.context import Context, SubContext, ContextItem
+
+import oils.utils.csedit
+import osrf.log
+import osrf.system
+from oils.utils.idl import oilsParseIDL
+from oils.utils.csedit import oilsLoadCSEditor
+
+def oilsConnect(config, configContext):
+ """Connects to the opensrf network, parses the IDL file, and loads the CSEditor"""
+ osrf.system.connect(config, configContext)
+ oilsParseIDL()
+ oilsLoadCSEditor()
+
+log = logging.getLogger(__name__)
+
+class AcqAdminController(BaseController):
+
+ def index(self):
+ """
+ List the acquisition objects that we're allowed to administer
+ """
+
+ import pprint
+
+ # Parse IDL and render as links for viewing the objects, perhaps?
+ c.oils = oilsweb.lib.context.Context.init(request)
+ c.request = request
+ oilsConnect('/openils/conf/opensrf_core.xml', 'config.opensrf')
+ c.idl = oils.utils.idl.oilsGetIDLParser()
+ c.csedit = oils.utils.csedit.CSEditor()
+ c.registry = osrf.net_obj.OBJECT_REGISTRY
+ return render('oils/%s/acq/admin.html' % c.oils.core.skin)
+
Added: 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 (rev 0)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/admin.html 2007-12-21 20:21:19 UTC (rev 8273)
@@ -0,0 +1,57 @@
+<%inherit file='../base.html'/>
+<%def name="block_title()">${_('Evergreen Acquisitions Administration ')}</%def>
+<%def name="block_content()">
+<h1>${_('Evergreen Acquisitions Administration ')}</h1>
+<pre>
+
+ Check for a session key in GET dictionary object:
+ % if c.request.GET.has_key('ses'):
+ SESSION = ${c.request.GET['ses']}
+ % else:
+ NO SESSION
+ % endif
+
+ Try some sample method calls - no session appears to be required,
+ possibly because I'm performing the connect in acq_admin.py
+ <%
+ csd = c.csedit.retrieve_acq_exchange_rate(1)
+ eur = c.csedit.retrieve_acq_exchange_rate(2)
+ %>
+ csd = c.csedit.retrieve_acq_exchange_rate(1)
+ csd.to_currency()
+ Result = ${csd.to_currency()}
+
+ eur = c.csedit.retrieve_acq_exchange_rate(2)
+ eur.to_currency()
+ Result = ${eur.to_currency()}
+
+ Iterate through the acq schema registry objects, dumping interesting info
+ that we should be able to wrap into a series of links and forms for
+ administrative purposes.
+
+ Registry:
+ % for key in sorted(c.registry):
+ % if c.idl.IDLObject.has_key(key) and str(c.idl.IDLObject[key]['tablename'])[0:4] == 'acq.':
+ registry hint: ${key}
+ tablename : ${c.idl.IDLObject[key]['tablename']}
+ controller : ${c.idl.IDLObject[key]['controller']}
+ virtual : ${c.idl.IDLObject[key]['virtual']}
+ fieldmapper : ${c.idl.IDLObject[key]['fieldmapper']}
+ KEYS
+ %for regkey in c.registry[key].keys:
+ ${regkey}
+ % endfor
+
+ % endif
+ % endfor
+
+ List the callable methods in the CSEditor object, more for interest than anything else:
+
+ CSEditor object:
+ % for att in [att for att in dir(c.csedit) if callable(getattr(c.csedit, att)) and att[0:2] != '__']:
+ ${att}
+ % endfor
+
+
+</pre>
+</%def>
More information about the open-ils-commits
mailing list