#!/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

##################################################
## 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__ = 1225031612.4095931
__CHEETAH_genTimestamp__ = 'Sun Oct 26 14:33:32 2008'
__CHEETAH_src__ = 'SearchBoxTemplate.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 SearchBoxTemplate(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 searchbox(self, s, **KWS):



        ## CHEETAH: generated from #def searchbox($s) at line 27, 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
        
        if VFFSL(SL,"s.form",True): # generated from line 28, col 1
            write('''   <form name="''')
            _v = VFFSL(SL,"s.formCname",True) # '$s.formCname' on line 29, col 16
            if _v is not None: write(_filter(_v, rawExpr='$s.formCname')) # from line 29, col 16.
            write('''" method="''')
            _v = VFFSL(SL,"s.method",True) # '$s.method' on line 29, col 38
            if _v is not None: write(_filter(_v, rawExpr='$s.method')) # from line 29, col 38.
            write('''"><p>
''')
        write('''   <table title="''')
        _v = VFFSL(SL,"s.help",True) # '$s.help' on line 31, col 18
        if _v is not None: write(_filter(_v, rawExpr='$s.help')) # from line 31, col 18.
        write('''" style="border: 1px solid #666; background-image:url(\'/images/form/fill-active.gif\');">
        <tr>
            <th colspan="3" style="text-align: left;">
                ''')
        _v = VFFSL(SL,"s.title",True) # '$s.title' on line 34, col 17
        if _v is not None: write(_filter(_v, rawExpr='$s.title')) # from line 34, col 17.
        write('''
        </tr>
''')
        if VFFSL(SL,"s.error",True): # generated from line 36, col 1
            write('''        <tr>
            <td colspan="3"><span style="color: #f00;font-size: 10">''')
            _v = VFFSL(SL,"s.error",True) # '$s.error' on line 38, col 69
            if _v is not None: write(_filter(_v, rawExpr='$s.error')) # from line 38, col 69.
            write('''</span></td>
        </tr>
''')
        if VFFSL(SL,"s.result",True): # generated from line 41, col 1
            write('''        <tr>
            <td colspan="3"><span style="color: #090;font-size: 10">''')
            _v = VFFSL(SL,"s.result",True) # '$s.result' on line 43, col 69
            if _v is not None: write(_filter(_v, rawExpr='$s.result')) # from line 43, col 69.
            write('''</span></td>
        </tr>
''')
        write('''        <tr>
            <td><select name="''')
        _v = VFFSL(SL,"s.typeCname",True) # '$s.typeCname' on line 47, col 31
        if _v is not None: write(_filter(_v, rawExpr='$s.typeCname')) # from line 47, col 31.
        write('''">
''')
        for sid,options in VFN(VFFSL(SL,"s.searches",True),"items",False)(): # generated from line 48, col 1
            if VFFSL(SL,"s.selected",True) == VFFSL(SL,"sid",True): # generated from line 49, col 1
                write('''            <option selected value="''')
                _v = VFFSL(SL,"sid",True) # '$sid' on line 50, col 37
                if _v is not None: write(_filter(_v, rawExpr='$sid')) # from line 50, col 37.
                write('''">''')
                _v = VFFSL(SL,"options",True)[0] # '$options[0]' on line 50, col 43
                if _v is not None: write(_filter(_v, rawExpr='$options[0]')) # from line 50, col 43.
                write('''</option>
''')
            else: # generated from line 51, col 1
                write('''            <option value="''')
                _v = VFFSL(SL,"sid",True) # '$sid' on line 52, col 28
                if _v is not None: write(_filter(_v, rawExpr='$sid')) # from line 52, col 28.
                write('''">''')
                _v = VFFSL(SL,"options",True)[0] # '$options[0]' on line 52, col 34
                if _v is not None: write(_filter(_v, rawExpr='$options[0]')) # from line 52, col 34.
                write('''</option>
''')
        write('''            </select></td>
            <td><input size="''')
        _v = VFFSL(SL,"s.inputSize",True) # '$s.inputSize' on line 56, col 30
        if _v is not None: write(_filter(_v, rawExpr='$s.inputSize')) # from line 56, col 30.
        write('''" type="text" name="''')
        _v = VFFSL(SL,"s.inputCname",True) # '$s.inputCname' on line 56, col 62
        if _v is not None: write(_filter(_v, rawExpr='$s.inputCname')) # from line 56, col 62.
        write('''"></td>
            <td><input type="submit" name="''')
        _v = VFFSL(SL,"s.submitCname",True) # '$s.submitCname' on line 57, col 44
        if _v is not None: write(_filter(_v, rawExpr='$s.submitCname')) # from line 57, col 44.
        write('''" value="''')
        _v = VFFSL(SL,"s.submitText",True) # '$s.submitText' on line 57, col 67
        if _v is not None: write(_filter(_v, rawExpr='$s.submitText')) # from line 57, col 67.
        write('''"></td>
        </tr>
    </table>
    </p>
''')
        if VFFSL(SL,"s.form",True): # generated from line 61, col 1
            write('''    </form>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    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: SearchBoxTemplate.tmpl 3809 2007-01-19 14:16:23Z jodal $
        #  Contains a template function for displaying a SearchBox object
        #   
        #  Copyright 2003, 2004 Norwegian University of Science and Technology
        # 
        #  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: Hans Jørgen Hoel <hansjorg@orakel.ntnu.no>
        # 
        write('''
''')
        
        ########################################
        ## 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_SearchBoxTemplate= 'respond'

## END CLASS DEFINITION

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


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


