# 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
--- /dev/null
+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)
+
--- /dev/null
+<%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>