[open-ils-commits] r8276 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb: lib
public/oils/media/css/skin public/oils/media/css/theme
templates/oils/default templates/oils/default/acq
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Dec 25 16:04:45 EST 2007
Author: erickson
Date: 2007-12-25 15:42:15 -0500 (Tue, 25 Dec 2007)
New Revision: 8276
Added:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/header.html
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/app_globals.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/default.css
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css
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/base.html
Log:
moved core context initialization into __init__, leaving context.py as a generic context handler. added header.html which just outputs the username/workstation
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-23 02:41:38 UTC (rev 8275)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py 2007-12-25 20:42:15 UTC (rev 8276)
@@ -0,0 +1,35 @@
+from oilsweb.lib.context import Context, SubContext, ContextItem
+import osrf.ses, oils.utils.csedit, pylons.config
+
+class CoreContext(SubContext):
+ def __init__(self):
+ self.prefix = ContextItem() # web prefi
+ 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.user = ContextItem() # logged in user object
+ self.workstation = ContextItem() # workstation object
+
+ def postinit(self):
+ import pylons.config
+ self.prefix = pylons.config['oils_prefix']
+ self.media_prefix = pylons.config['oils_media_prefix']
+ self.ac_prefix = pylons.config['oils_added_content_prefix']
+
+ self.skin = 'default' # XXX
+ self.theme = 'default' # XXX
+
+ self.fetchUser()
+
+ def fetchUser(self):
+ ''' Grab the logged in user and their workstation '''
+ if self.authtoken:
+ self.user = osrf.ses.AtomicRequest(
+ 'open-ils.auth',
+ 'open-ils.auth.session.retrieve', self.authtoken)
+ self.workstation = oils.utils.csedit.CSEditor().retrieve_actor_workstation(self.user.wsid())
+
+Context.applySubContext('core', CoreContext)
+
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/app_globals.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/app_globals.py 2007-12-23 02:41:38 UTC (rev 8275)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/app_globals.py 2007-12-25 20:42:15 UTC (rev 8276)
@@ -8,7 +8,6 @@
"""
def __init__(self):
- #oilsweb.lib.util.childInit()
- self.oils_authtoken = None
+ pass
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-23 02:41:38 UTC (rev 8275)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/context.py 2007-12-25 20:42:15 UTC (rev 8276)
@@ -1,11 +1,11 @@
from oilsweb.lib.util import childInit
-import pylons.config
import cgi
_context = None
_subContexts = {}
class ContextItem(object):
+ ''' Defines a single field on a subcontext object. '''
def __init__(self, **kwargs):
self.app = None
self.name = kwargs.get('name')
@@ -14,19 +14,28 @@
self.qname = None
self.multi = kwargs.get('multi')
+class SubContext(object):
+ ''' A SubContext is a class-specific context object that lives inside the global context object '''
+ def _fields(self):
+ ''' Returns all public fields for this subcontext '''
+ return [ f for f in dir(self) if f[0:1] != '_' and
+ getattr(self, f).__class__.__name__.find('function') < 0 and
+ getattr(self, f).__class__.__name__.find('method') < 0 ]
+
+ def postinit(self):
+ ''' Overide with any post-global-init initialization '''
+ pass
+
class Context(object):
+ ''' Global context object '''
+
def __init__(self):
self._fields = []
- def wrap(self):
- return {'oils': self}
-
- '''
- def applySubContext(self, app, subContext):
- setattr(self, app, subContext)
- '''
-
def make_query_string(self):
+ ''' Compiles a CGI query string from the collection of values
+ stored in the subcontexts '''
+
q = ''
for f in self._fields:
if f.cgi_name:
@@ -39,7 +48,10 @@
else:
if isinstance(val, str) or isinstance(val, unicode):
q += f.cgi_name+'='+cgi.escape(val)+'&'
- if len(q) > 0: q = q[:-1] # strip the trailing &
+
+ if len(q) > 0:
+ q = q[:-1] # strip the trailing &
+
return q
@staticmethod
@@ -74,30 +86,10 @@
else:
setattr(getattr(c, app), name, item.default_value)
- # store the metatdata at _<name>
+ # store the metatdata at <name>_
setattr(getattr(c, app), "%s_" % name, item)
- c.core.prefix = pylons.config['oils_prefix']
- c.core.media_prefix = pylons.config['oils_media_prefix']
- c.core.ac_prefix = pylons.config['oils_added_content_prefix']
+ ctx.postinit()
- c.core.skin = 'default' # XXX
- c.core.theme = 'default' # XXX
-
return c
-
-class SubContext(object):
- def _fields(self):
- return [ f for f in dir(self) if f[0:1] != '_' ]
-
-class CoreContext(SubContext):
- def __init__(self):
- self.prefix = ContextItem()
- self.media_prefix = ContextItem()
- self.ac_prefix = ContextItem()
- self.skin = ContextItem()
- self.theme = ContextItem()
- self.authtoken = ContextItem(cgi_name='ses')
-Context.applySubContext('core', CoreContext)
-
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css 2007-12-23 02:41:38 UTC (rev 8275)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css 2007-12-25 20:42:15 UTC (rev 8276)
@@ -7,14 +7,15 @@
/* use this for divs whose contents should be entirely contained within the div */
.container:after {content: ""; display: block; height: 0; clear: both; }
table { border-collapse: collapse; }
+body { margin-top: 0px; padding-top: 0px;}
-#oils-base-body-block { width: 100%; }
-#oils-base-main-block { width: 100%; }
+#oils-base-body-block { width: 100%; margin-top: 0px; padding-top: 0px;}
+#oils-base-main-block { width: 100%; margin-top: 0px; padding-top: 0px;}
#oils-base-navigate-block { width: 15%; vertical-align: top; float:left;}
-#oils-base-content-block { width: 84%; vertical-align: top; float:right;}
+#oils-base-content-block { width: 84%; vertical-align: top; float:right; padding-top: 8px;}
#oils-base-sidebar-block { width: 15%; vertical-align: top; float:left;}
-#oils-base-header-block { width: 100%; text-align: center; vertical-align: bottom;}
+#oils-base-header-block { width: 84%; text-align: right; margin-top: 0px; float:right;}
#oils-base-footer-block { width: 100%; text-align: center; vertical-align: bottom;}
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css 2007-12-23 02:41:38 UTC (rev 8275)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css 2007-12-25 20:42:15 UTC (rev 8276)
@@ -9,6 +9,7 @@
#oils-base-content-block {}
#oils-base-sidebar-block {}
#oils-base-footer-block {padding: 3px; margin-top: 20px; border: 1px solid #808080;}
+#oils-base-header-block {border-bottom: 1px solid #909090; }
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 2007-12-23 02:41:38 UTC (rev 8275)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html 2007-12-25 20:42:15 UTC (rev 8276)
@@ -3,12 +3,8 @@
<%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}'/>
+ <input type='hidden' name='${c.oils.core.authtoken_.cgi_name}' value='${c.oils.core.authtoken}'/>
<table id='oils-acq-pl_builder-table'>
- <!--
- <thead>
- <tr><td>${_('Add To Picklist')}</td><td>${_('Title')}</td><td>${_('Author')}</td><td>${_('Source')}</td></tr>
- </thead>
- -->
<tbody>
<%include file="record_list.html"/>
<!--
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 2007-12-23 02:41:38 UTC (rev 8275)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/base.html 2007-12-25 20:42:15 UTC (rev 8276)
@@ -2,13 +2,13 @@
<%def name='block_body_content()'>
<div id='oils-base-body-block'>
- <div id='oils-base-header-block'>
- ${self.block_header()}
- </div>
<div id='oils-base-main-block' class='container'>
<div id='oils-base-navigate-block'>
${self.block_navigate()}
</div>
+ <div id='oils-base-header-block'>
+ ${self.block_header()}
+ </div>
<div id='oils-base-content-block'>
${self.block_content()}
</div>
@@ -22,7 +22,9 @@
</div>
</%def>
-<%def name='block_header()'/>
+<%def name='block_header()'>
+ <%include file='header.html'/>
+</%def>
<%def name='block_sidebar()'/>
<%def name='block_content()'/>
<%def name='block_navigate()'>
Added: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/header.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/header.html (rev 0)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/header.html 2007-12-25 20:42:15 UTC (rev 8276)
@@ -0,0 +1,3 @@
+<div id='oils-base-header-content-div'>
+ ${c.oils.core.user.usrname()} / ${c.oils.core.workstation.name()}
+</div>
More information about the open-ils-commits
mailing list