All pastes #136513 Raw Edit

Miscellany

public text v1 · immutable
#136513 ·published 2006-08-17 18:55 UTC
rendered paste body
ZPT
<form method=get tal:attributes="action string:${here/absolute_url}/consulta_cliente_py">
   <table border="1" width="50%">
     <tr>
       <th>Consultar</th>
         <td><input type="text" name="consulta_cliente" value="" maxlenght="40" size="40" style="text-transform:uppercase;"> <input type="submit" value="Consultar" name=""></td>
     </tr> 
   </table><br/>
</form>

<table border="1">
  <metal:block tal:define="items options/parametro | nothing" 
               tal:condition="exists:items" 
               tal:repeat="resultados items">

     <tr tal:define="pintar repeat/resultados/even"
         tal:attributes="bgcolor python:test(pintar, '#FFFFE0', '#FFFFFF')">
         <td><p tal:content="resultados/nomefantasia"/></td>       
     </tr>
  </metal:block>
</table>



PyScript
# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote
request = container.REQUEST
RESPONSE =  request.RESPONSE

nomefantasia = request.get('consulta_cliente')
mensagem = ""
consulta = []

if nomefantasia == "" or len(nomefantasia) < 3:
   mensagem = "Você precisa inserir pelo menos 3 caracteres para consulta"
   return RESPONSE.redirect('%s/consulta_cliente?mensagem=%s' % (context.absolute_url(),mensagem))
else:
   consulta = context.zsql_select_cliente(nomefantasia=nomefantasia.upper())
   return context.consulta_cliente(parametro=consulta)