#!/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
import mx.DateTime

##################################################
## 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__ = 1225031607.1156089
__CHEETAH_genTimestamp__ = 'Sun Oct 26 14:33:27 2008'
__CHEETAH_src__ = 'nav/web/templates/MessagesFeedTemplate.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 MessagesFeedTemplate(Template):

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


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

        Template.__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 respond(self, trans=None):



        ## CHEETAH: main method generated for this template
        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>
        # 
        #  FIXME: %Z can be empty, but we should always give a timezone such as
        #  '+02:00' for CEST and '+01:00' for CET
        lastBuildDate = mx.DateTime.now().strftime('%a, %d %b %Y %H:%M:%S %Z')
        write('''<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0">
    <channel>
        <title>''')
        _v = VFN(VFN(VFFSL(SL,"channeltitle",True),"replace",False)('<', '&lt;'),"replace",False)('>', '&gt;') # "$channeltitle.replace('<', '&lt;').replace('>', '&gt;')" on line 33, col 16
        if _v is not None: write(_filter(_v, rawExpr="$channeltitle.replace('<', '&lt;').replace('>', '&gt;')")) # from line 33, col 16.
        write('''</title>
        <link>''')
        _v = VFFSL(SL,"channellink",True) # '$channellink' on line 34, col 15
        if _v is not None: write(_filter(_v, rawExpr='$channellink')) # from line 34, col 15.
        write('''</link>
        <description>''')
        _v = VFN(VFN(VFFSL(SL,"channeldesc",True),"replace",False)('<', '&lt;'),"replace",False)('>', '&gt;') # "$channeldesc.replace('<', '&lt;').replace('>', '&gt;')" on line 35, col 22
        if _v is not None: write(_filter(_v, rawExpr="$channeldesc.replace('<', '&lt;').replace('>', '&gt;')")) # from line 35, col 22.
        write('''</description>
        <language>''')
        _v = VFFSL(SL,"channellang",True) # '$channellang' on line 36, col 19
        if _v is not None: write(_filter(_v, rawExpr='$channellang')) # from line 36, col 19.
        write('''</language>
        <pubDate>''')
        _v = VFN(VFFSL(SL,"pubDate",True),"strftime",False)('%a, %d %b %Y %H:%M:%S %Z') # "$pubDate.strftime('%a, %d %b %Y %H:%M:%S %Z')" on line 37, col 18
        if _v is not None: write(_filter(_v, rawExpr="$pubDate.strftime('%a, %d %b %Y %H:%M:%S %Z')")) # from line 37, col 18.
        write('''</pubDate>
        <lastBuildDate>''')
        _v = VFFSL(SL,"lastBuildDate",True) # '$lastBuildDate' on line 38, col 24
        if _v is not None: write(_filter(_v, rawExpr='$lastBuildDate')) # from line 38, col 24.
        write('''</lastBuildDate>
        <ttl>''')
        _v = VFFSL(SL,"channelttl",True) # '$channelttl' on line 39, col 14
        if _v is not None: write(_filter(_v, rawExpr='$channelttl')) # from line 39, col 14.
        write('''</ttl>
        
''')
        msgs = VFFSL(SL,"getVar",False)('msgs', [])
        for msg in msgs: # generated from line 42, col 9
            write('''        <item>
            <title>''')
            _v = VFN(VFN(VFFSL(SL,"msg.title",True),"replace",False)('<', '&lt;'),"replace",False)('>', '&gt;') # "$msg.title.replace('<', '&lt;').replace('>', '&gt;')" on line 44, col 20
            if _v is not None: write(_filter(_v, rawExpr="$msg.title.replace('<', '&lt;').replace('>', '&gt;')")) # from line 44, col 20.
            write('''</title>
            <pubDate>''')
            _v = VFN(VFFSL(SL,"msg.publish_start",True),"strftime",False)('%a, %d %b %Y %H:%M:%S %Z') # "$msg.publish_start.strftime('%a, %d %b %Y %H:%M:%S %Z')" on line 45, col 22
            if _v is not None: write(_filter(_v, rawExpr="$msg.publish_start.strftime('%a, %d %b %Y %H:%M:%S %Z')")) # from line 45, col 22.
            write('''</pubDate>
            <link>''')
            _v = VFFSL(SL,"msg.link",True) # '$msg.link' on line 46, col 19
            if _v is not None: write(_filter(_v, rawExpr='$msg.link')) # from line 46, col 19.
            write('''</link>
            <guid>''')
            _v = VFFSL(SL,"msg.guid",True) # '$msg.guid' on line 47, col 19
            if _v is not None: write(_filter(_v, rawExpr='$msg.guid')) # from line 47, col 19.
            write('''</guid>
            <comments />
            <description>''')
            _v = VFN(VFN(VFFSL(SL,"msg.description",True),"replace",False)('<', '&lt;'),"replace",False)('>', '&gt;') # "$msg.description.replace('<', '&lt;').replace('>', '&gt;')" on line 49, col 26
            if _v is not None: write(_filter(_v, rawExpr="$msg.description.replace('<', '&lt;').replace('>', '&gt;')")) # from line 49, col 26.
            write('''</description>
        </item>
''')
        write('''    </channel>
</rss>
''')
        
        ########################################
        ## 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_MessagesFeedTemplate= 'respond'

## END CLASS DEFINITION

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


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


