moved core context initialization into __init__, leaving context.py as a generic...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 25 Dec 2007 20:42:15 +0000 (20:42 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 25 Dec 2007 20:42:15 +0000 (20:42 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8276 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/lib/__init__.py
Open-ILS/web/oilsweb/oilsweb/lib/app_globals.py
Open-ILS/web/oilsweb/oilsweb/lib/context.py
Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css
Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/pl_builder.html
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/base.html
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/header.html [new file with mode: 0644]

index e69de29..9db4e81 100644 (file)
@@ -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)
+
index 77ad4ed..bf97da2 100644 (file)
@@ -8,7 +8,6 @@ class Globals(object):
     """
 
     def __init__(self):
-        #oilsweb.lib.util.childInit()
-        self.oils_authtoken = None
+        pass
 
 
index 6badcfa..84d5182 100644 (file)
@@ -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 _<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']
-
-        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)
-
index a27bf42..d1231c2 100644 (file)
@@ -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;}
 
 
index 6808bef..936402f 100644 (file)
@@ -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; }
 
 
 
index f56021c..4b3d4f5 100644 (file)
@@ -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"/>
         <!--
index f0368de..58183fc 100644 (file)
@@ -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()'>
diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/header.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/header.html
new file mode 100644 (file)
index 0000000..17cd246
--- /dev/null
@@ -0,0 +1,3 @@
+<div id='oils-base-header-content-div'>
+    ${c.oils.core.user.usrname()} / ${c.oils.core.workstation.name()}
+</div>