#!/usr/bin/env python
# -*- coding: UTF-8 -*-



##################################################
## DEPENDENCIES
import sys
import os
import os.path
from os.path import getmtime, exists
import time
import types
import __builtin__
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
from Cheetah.Template import Template
from Cheetah.DummyTransaction import DummyTransaction
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
from Cheetah.CacheRegion import CacheRegion
import Cheetah.Filters as Filters
import Cheetah.ErrorCatchers as ErrorCatchers
from MainTemplate import MainTemplate

##################################################
## MODULE CONSTANTS
try:
    True, False
except NameError:
    True, False = (1==1), (1==0)
VFFSL=valueFromFrameOrSearchList
VFSL=valueFromSearchList
VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.0.1'
__CHEETAH_versionTuple__ = (2, 0, 1, 'final', 0)
__CHEETAH_genTime__ = 1225031608.057452
__CHEETAH_genTimestamp__ = 'Sun Oct 26 14:33:28 2008'
__CHEETAH_src__ = 'nav/web/templates/MessagesTemplate.tmpl'
__CHEETAH_srcLastModified__ = 'Fri Jan 19 14:16:23 2007'
__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 MessagesTemplate(MainTemplate):

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


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

        MainTemplate.__init__(self, *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 additionalHead(self, **KWS):



        ## CHEETAH: generated from #def additionalHead at line 31, 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('''    <link rel="alternate" type="application/rss+xml"
        title="Messages Feed (RSS 2.0)" href="/messages/rss" />
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def makeMenu(self, menu, current=False, **KWS):



        ## CHEETAH: generated from #def $makeMenu($menu, $current = False) at line 36, 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('''<div style="border: 1px solid black; margin: 36px 0px 15px 0px; padding: 0px 19px;">
<div id="tabs" style="margin: -24px -10px;">
<ul>
''')
        for item in VFFSL(SL,"menu",True): # generated from line 40, col 1
            if VFFSL(SL,"item.link",True) == VFFSL(SL,"current",True): # generated from line 41, col 5
                write('''    <li id="current"><a>''')
                _v = VFFSL(SL,"item.text",True) # '$item.text' on line 42, col 25
                if _v is not None: write(_filter(_v, rawExpr='$item.text')) # from line 42, col 25.
                write('''</a></li>
''')
            elif VFFSL(SL,"item.admin",True): # generated from line 43, col 5
                write('''    <li><a href="''')
                _v = VFFSL(SL,"item.link",True) # '$item.link' on line 44, col 18
                if _v is not None: write(_filter(_v, rawExpr='$item.link')) # from line 44, col 18.
                write('''">''')
                _v = VFFSL(SL,"item.text",True) # '$item.text' on line 44, col 30
                if _v is not None: write(_filter(_v, rawExpr='$item.text')) # from line 44, col 30.
                write('''</a></li>
''')
            else: # generated from line 45, col 5
                write('''    <li class="open"><a href="''')
                _v = VFFSL(SL,"item.link",True) # '$item.link' on line 46, col 31
                if _v is not None: write(_filter(_v, rawExpr='$item.link')) # from line 46, col 31.
                write('''">''')
                _v = VFFSL(SL,"item.text",True) # '$item.text' on line 46, col 43
                if _v is not None: write(_filter(_v, rawExpr='$item.text')) # from line 46, col 43.
                write('''</a></li>
''')
        write('''</ul>
</div>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def tabcontent(self, **KWS):



        ## CHEETAH: generated from #block tabcontent at line 79, 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('''<p>Intentionally left blank.</p>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def content(self, **KWS):



        ## CHEETAH: generated from #block content at line 53, 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('''
''')
        _v = VFFSL(SL,"makeMenu",False)(VFFSL(SL,"menu",True), VFFSL(SL,"current",True)) # '$makeMenu($menu, $current)' on line 55, col 1
        if _v is not None: write(_filter(_v, rawExpr='$makeMenu($menu, $current)')) # from line 55, col 1.
        write('''

<h2>''')
        _v = VFFSL(SL,"title",True) # '$title' on line 57, col 5
        if _v is not None: write(_filter(_v, rawExpr='$title')) # from line 57, col 5.
        write('''</h2>

''')
        infomsgs = VFFSL(SL,"getVar",False)('infomsgs', [])
        if len(VFFSL(SL,"infomsgs",True)): # generated from line 60, col 1
            write('''<ul>
''')
            for infomsg in VFFSL(SL,"infomsgs",True): # generated from line 62, col 1
                write('''    <li>''')
                _v = VFFSL(SL,"infomsg",True) # '$infomsg' on line 63, col 9
                if _v is not None: write(_filter(_v, rawExpr='$infomsg')) # from line 63, col 9.
                write('''</li>
''')
            write('''</ul>
''')
        write('''
''')
        errors = VFFSL(SL,"getVar",False)('errors', [])
        if len(VFFSL(SL,"errors",True)): # generated from line 69, col 1
            write('''<p>The following errors occured:</p>

<ul>
''')
            for error in VFFSL(SL,"errors",True): # generated from line 73, col 1
                write('''    <li>''')
                _v = VFFSL(SL,"error",True) # '$error' on line 74, col 9
                if _v is not None: write(_filter(_v, rawExpr='$error')) # from line 74, col 9.
                write('''</li>
''')
            write('''</ul>
''')
        write('''
''')
        self.tabcontent(trans=trans)
        write('''
</div> <!-- tab area -->

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

    def additionalCSS(self, **KWS):



        ## CHEETAH: generated from #block additionalCSS at line 87, 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
        
        _v = VFFSL(SL,"default_tabs_CSS",True) # '$default_tabs_CSS' on line 88, col 1
        if _v is not None: write(_filter(_v, rawExpr='$default_tabs_CSS')) # from line 88, col 1.
        write('''
''')
        _v = VFFSL(SL,"default_table_CSS",True) # '$default_table_CSS' on line 89, col 1
        if _v is not None: write(_filter(_v, rawExpr='$default_table_CSS')) # from line 89, col 1.
        write('''
''')
        
        ########################################
        ## 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
        
        #  $Id: $
        # 
        #  Copyright 2006 UNINETT AS
        # 
        #  This file is part of Network Administration Visualized (NAV)
        # 
        #  NAV is free software; you can redistribute it and/or modify
        #  it under the terms of the GNU General Public License as published by
        #  the Free Software Foundation; either version 2 of the License, or
        #  (at your option) any later version.
        # 
        #  NAV is distributed in the hope that it will be useful,
        #  but WITHOUT ANY WARRANTY; without even the implied warranty of
        #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        #  GNU General Public License for more details.
        # 
        #  You should have received a copy of the GNU General Public License
        #  along with NAV; if not, write to the Free Software
        #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        # 
        # 
        #  Author: Stein Magnus Jodal <stein.magnus.jodal@uninett.no>
        # 
        write('''

''')
        # attr $title = 'Messages'
        write('''


''')
        self.content(trans=trans)
        write('''
''')
        self.additionalCSS(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__

    path = [("Home", "/"), ("Messages", "")]

    _mainCheetahMethod_for_MessagesTemplate= 'writeBody'

## END CLASS DEFINITION

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


# 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=MessagesTemplate()).run()


