From: erickson Date: Tue, 25 Dec 2007 20:42:15 +0000 (+0000) Subject: moved core context initialization into __init__, leaving context.py as a generic... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=71755050fee78028dc8fa83d07ba3d5195f3bef7;p=Evergreen.git moved core context initialization into __init__, leaving context.py as a generic context handler. added header.html which just outputs the username/workstation git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8276 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py b/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py index e69de29bb2..9db4e818a0 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py @@ -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) + diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/app_globals.py b/Open-ILS/web/oilsweb/oilsweb/lib/app_globals.py index 77ad4eddd9..bf97da2852 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/app_globals.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/app_globals.py @@ -8,7 +8,6 @@ class Globals(object): """ def __init__(self): - #oilsweb.lib.util.childInit() - self.oils_authtoken = None + pass diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/context.py b/Open-ILS/web/oilsweb/oilsweb/lib/context.py index 6badcfa99a..84d51824e3 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/context.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/context.py @@ -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 @@ class ContextItem(object): 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 @@ class Context(object): 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 @@ class Context(object): else: setattr(getattr(c, app), name, item.default_value) - # store the metatdata at _ + # store the metatdata at _ 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'] - - c.core.skin = 'default' # XXX - c.core.theme = 'default' # XXX + ctx.postinit() 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) - diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css index a27bf42b5a..d1231c24ef 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css @@ -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;} diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css index 6808bef3c1..936402f0ae 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css @@ -9,6 +9,7 @@ body { font-size: 85%; } #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; } diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html index f56021c19f..4b3d4f5a13 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html @@ -3,12 +3,8 @@ <%def name="block_content()">
+ - <%include file="record_list.html"/>