#!/usr/bin/env python




##################################################
## DEPENDENCIES
import sys
import os
import os.path
try:
    import builtins as builtin
except ImportError:
    import __builtin__ as builtin
from os.path import getmtime, exists
import time
import types
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
from Cheetah.Template import Template
from Cheetah.DummyTransaction import *
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
from Cheetah.CacheRegion import CacheRegion
import Cheetah.Filters as Filters
import Cheetah.ErrorCatchers as ErrorCatchers
from prewikka.templates.ClassicLayout import ClassicLayout

##################################################
## MODULE CONSTANTS
VFFSL=valueFromFrameOrSearchList
VFSL=valueFromSearchList
VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.4.4'
__CHEETAH_versionTuple__ = (2, 4, 4, 'development', 0)
__CHEETAH_genTime__ = 1313541190.714574
__CHEETAH_genTimestamp__ = 'Tue Aug 16 18:33:10 2011'
__CHEETAH_src__ = 'prewikka/templates/MessageSummary.tmpl'
__CHEETAH_srcLastModified__ = 'Tue May  5 08:55:59 2009'
__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'

if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
    raise AssertionError(
      'This template was compiled with Cheetah version'
      ' %s. Templates compiled before version %s must be recompiled.'%(
         __CHEETAH_version__, RequiredCheetahVersion))

##################################################
## CLASSES

class MessageSummary(ClassicLayout):

    ##################################################
    ## CHEETAH GENERATED METHODS


    def __init__(self, *args, **KWs):

        super(MessageSummary, self).__init__(*args, **KWs)
        if not self._CHEETAH__instanceInitialized:
            cheetahKWArgs = {}
            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
            for k,v in KWs.items():
                if k in allowedKWs: cheetahKWArgs[k] = v
            self._initCheetahInstance(**cheetahKWArgs)
        

    def layout_start_hook(self, **KWS):



        ## CHEETAH: generated from #def layout_start_hook at line 3, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        write(u'''<script type="text/javascript">
<!--
$(document).ready(function() {

 $("legend a").click(function(){
    var $div = $(this).parent().next();

    if ( $div.is(":hidden") )
        $div.show(\'normal\');
    else
        $div.hide(\'normal\');

    return false;
  });
});

//--></script>

''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def display_table(self, section, depth, **KWS):



        ## CHEETAH: generated from #def display_table($section, $depth) at line 29, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        write(u'''
''')
        table_cnt = 0
        for table in VFFSL(SL,"section.tables",True): # generated from line 32, col 3
            write(u'''\t\t
''')
            if VFFSL(SL,"depth",True) == 0 and VFFSL(SL,"table_cnt",True) > 0 and VFN(VFFSL(SL,"table.style",True),"find",False)("inline") == -1: # generated from line 34, col 3
                write(u'''\t\t  <br/>
''')
            write(u'''
''')
            if VFFSL(SL,"table.odd_even",True): # generated from line 38, col 17
                write(u'''\t\t<table class="''')
                _v = VFFSL(SL,"table.class",True) # u'$table.class' on line 39, col 17
                if _v is not None: write(_filter(_v, rawExpr=u'$table.class')) # from line 39, col 17.
                write(u''' ''')
                _v = VFFSL(SL,"row_classes",True)[VFFSL(SL,"table_cnt",True) % 2] # u'$row_classes[$table_cnt % 2]' on line 39, col 30
                if _v is not None: write(_filter(_v, rawExpr=u'$row_classes[$table_cnt % 2]')) # from line 39, col 30.
                write(u'''" style="''')
                _v = VFFSL(SL,"table.style",True) # u'$table.style' on line 39, col 67
                if _v is not None: write(_filter(_v, rawExpr=u'$table.style')) # from line 39, col 67.
                write(u'''">
''')
            else: # generated from line 40, col 3
                write(u'''\t\t<table class="''')
                _v = VFFSL(SL,"table.class",True) # u'$table.class' on line 41, col 17
                if _v is not None: write(_filter(_v, rawExpr=u'$table.class')) # from line 41, col 17.
                write(u'''" style="''')
                _v = VFFSL(SL,"table.style",True) # u'$table.style' on line 41, col 38
                if _v is not None: write(_filter(_v, rawExpr=u'$table.style')) # from line 41, col 38.
                write(u'''">
''')
            write(u'''
''')
            table_cnt += 1
            row_class = ""
            for row in VFFSL(SL,"table.rows",True): # generated from line 46, col 4
                write(u'''\t\t  <tr class="''')
                _v = VFFSL(SL,"row_class",True) # u'$row_class' on line 47, col 16
                if _v is not None: write(_filter(_v, rawExpr=u'$row_class')) # from line 47, col 16.
                write(u'''" style="">
''')
                for col in row: # generated from line 48, col 6
                    if VFFSL(SL,"col.header",True): # generated from line 49, col 7
                        write(u'''\t\t     <th>''')
                        _v = VFFSL(SL,"col.name",True) # u'$col.name' on line 50, col 12
                        if _v is not None: write(_filter(_v, rawExpr=u'$col.name')) # from line 50, col 12.
                        write(u'''</th>
''')
                        row_class = "table_row_even"
                    elif VFFSL(SL,"col.tables",True): # generated from line 52, col 7
                        write(u'''\t\t     <td>''')
                        _v = VFFSL(SL,"display_table",False)(VFFSL(SL,"col",True), VFFSL(SL,"depth",True) + 1) # u'$display_table($col, $depth + 1)' on line 53, col 12
                        if _v is not None: write(_filter(_v, rawExpr=u'$display_table($col, $depth + 1)')) # from line 53, col 12.
                        write(u'''</td>
''')
                        row_class = ""
                    else: # generated from line 55, col 21
                        write(u'''\t\t     <td class="''')
                        _v = VFFSL(SL,"col.class",True) # u'$col.class' on line 56, col 19
                        if _v is not None: write(_filter(_v, rawExpr=u'$col.class')) # from line 56, col 19.
                        write(u'''">''')
                        _v = VFFSL(SL,"col.name",True) # u'$col.name' on line 56, col 31
                        if _v is not None: write(_filter(_v, rawExpr=u'$col.name')) # from line 56, col 31.
                        write(u'''</td>
''')
                write(u'''\t\t  </tr>
''')
            write(u'''\t\t</table>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def display_node(self, sections, **KWS):



        ## CHEETAH: generated from #def display_node($sections) at line 66, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        for section in VFFSL(SL,"sections",True): # generated from line 67, col 1
            write(u'''        <fieldset class="fieldset_heading">
\t\t<legend><a href="#">''')
            _v = VFFSL(SL,"section.title",True) # u'$section.title' on line 69, col 23
            if _v is not None: write(_filter(_v, rawExpr=u'$section.title')) # from line 69, col 23.
            write(u'''</a></legend>
\t\t<div style="display: ''')
            _v = VFFSL(SL,"section.display",True) # u'$section.display' on line 70, col 24
            if _v is not None: write(_filter(_v, rawExpr=u'$section.display')) # from line 70, col 24.
            write(u'''; width: 100%;">
\t\t''')
            _v = VFFSL(SL,"display_table",False)(VFFSL(SL,"section",True), 0) # u'$display_table($section, 0)' on line 71, col 3
            if _v is not None: write(_filter(_v, rawExpr=u'$display_table($section, 0)')) # from line 71, col 3.
            write(u'''

''')
            if VFFSL(SL,"section.entries",True): # generated from line 73, col 3
                write(u'''\t\t<table class="section_alert_entries">
\t\t\t
''')
                cnt = 0
                for entry in VFFSL(SL,"section.entries",True): # generated from line 77, col 4
                    write(u'''
                             
\t\t\t\t<tr class="section_alert_entry ''')
                    _v = VFFSL(SL,"row_classes",True)[VFFSL(SL,"cnt",True) % 2] # u'$row_classes[$cnt % 2]' on line 80, col 36
                    if _v is not None: write(_filter(_v, rawExpr=u'$row_classes[$cnt % 2]')) # from line 80, col 36.
                    write(u'''">
''')
                    if VFFSL(SL,"entry.name",True): # generated from line 81, col 19
                        write(u'''                                 <th style="text-align: left; width:150px;">''')
                        _v = VFFSL(SL,"entry.name",True) # u'$entry.name' on line 82, col 77
                        if _v is not None: write(_filter(_v, rawExpr=u'$entry.name')) # from line 82, col 77.
                        write(u'''</th>
''')
                    write(u'''\t\t\t\t <td class="''')
                    _v = VFFSL(SL,"entry_value_classes",True)[VFFSL(SL,"entry.emphase",True)] # u'$entry_value_classes[$entry.emphase]' on line 84, col 17
                    if _v is not None: write(_filter(_v, rawExpr=u'$entry_value_classes[$entry.emphase]')) # from line 84, col 17.
                    write(u'''">''')
                    _v = VFFSL(SL,"entry.value",True) # u'$entry.value' on line 84, col 55
                    if _v is not None: write(_filter(_v, rawExpr=u'$entry.value')) # from line 84, col 55.
                    write(u'''</td>
\t\t\t\t</tr>

''')
                    cnt += 1
                write(u'''\t\t</table>
''')
            write(u'''
''')
            self._CHEETAH__globalSetVars["section_cnt"] += 1
            write(u'''
''')
            if VFFSL(SL,"section.sections",True): # generated from line 94, col 3
                write(u'''\t\t    ''')
                _v = VFFSL(SL,"display_node",False)(VFFSL(SL,"section.sections",True)) # u'$display_node($section.sections)' on line 95, col 7
                if _v is not None: write(_filter(_v, rawExpr=u'$display_node($section.sections)')) # from line 95, col 7.
                write(u'''
''')
            write(u'''
\t\t</div>

\t</fieldset>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def main_content(self, **KWS):



        ## CHEETAH: generated from #block main_content at line 24, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        self._CHEETAH__globalSetVars["section_cnt"] = 0
        self._CHEETAH__globalSetVars["row_classes"] = ("table_row_even", "table_row_odd")
        self._CHEETAH__globalSetVars["entry_value_classes"] = ("section_alert_entry_value_normal", "section_alert_entry_value_emphasis")
        write(u'''



<div id="fieldset_page">
''')
        _v = VFFSL(SL,"display_node",False)(VFFSL(SL,"sections",True)) # u'$display_node($sections)' on line 105, col 1
        if _v is not None: write(_filter(_v, rawExpr=u'$display_node($sections)')) # from line 105, col 1.
        write(u'''
</div>

''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def writeBody(self, **KWS):



        ## CHEETAH: main method generated for this template
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        write(u'''

''')
        self.main_content(trans=trans)
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        
    ##################################################
    ## CHEETAH GENERATED ATTRIBUTES


    _CHEETAH__instanceInitialized = False

    _CHEETAH_version = __CHEETAH_version__

    _CHEETAH_versionTuple = __CHEETAH_versionTuple__

    _CHEETAH_genTime = __CHEETAH_genTime__

    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__

    _CHEETAH_src = __CHEETAH_src__

    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__

    _mainCheetahMethod_for_MessageSummary= 'writeBody'

## END CLASS DEFINITION

if not hasattr(MessageSummary, '_initCheetahAttributes'):
    templateAPIClass = getattr(MessageSummary, '_CHEETAH_templateClass', Template)
    templateAPIClass._addCheetahPlumbingCodeToClass(MessageSummary)


# CHEETAH was developed by Tavis Rudd and Mike Orr
# with code, advice and input from many other volunteers.
# For more information visit http://www.CheetahTemplate.org/

##################################################
## if run from command line:
if __name__ == '__main__':
    from Cheetah.TemplateCmdLineIface import CmdLineIface
    CmdLineIface(templateObj=MessageSummary()).run()


