I believe the problem is that it's expecting a compiled template at  
self.template. Take a look at Widget.display() and you'll see what  
it's trying to do when you call form().

You could override render() or something like that to do what you want.

I'm not a fan of string concatenation myself, but to each their own...

Kevin


On Sep 18, 2006, at 8:18 AM, Fernando Aires wrote:

>    I was looking on how to create widgets, but (maybe my fault) find
> nothing useful but the Widget class source code. Can somebody give me
> some help about that?
>    Downside there's the class code. Explanations below:
>
> class MapaReserva(widgets.Widget):
>         def __init__(self, name=None, datetime=now(), *args, **kw):
>                 super(MapaReserva, self).__init__(*args, **kw)
>                 nomesDiasSemana= 
> ["Seg","Ter","Qua","Qui","Sex","Sab","Dom"]
>                 strDiasSemana=""
>                 strDiasMes=""
>                 strDisponibilidade=""
>                 self.datetime=datetime-(datetime.day)+1
>                 dataInicial = self.datetime
>                 dataFinal = self.datetime+ 
> (self.datetime.days_in_month)-1
>                 for i in xrange(self.datetime.days_in_month):
>
> strDiasSemana+="<TD>"+str(nomesDiasSemana 
> [self.datetime.day_of_week])+"</TD>"
>                         strDiasMes+="<TD>"+str(self.datetime.day) 
> +"</TD>"
>                         self.datetime+=1
>                 self.datetime-=1
>                 self.datetime-=(datetime.day)-1
>                 for tipoApto in Regras.getTiposApartamentos():
>                         strDisponibilidade+='<TR><TD
> colspan="2">%s</TD>' % tipoApto.nome
>                         listaDiarias =
> Regras.getNumeroApartamentosLivres(dataInicial, dataFinal,
> tipoApto.idT
> ipo)
>                         for numeroAptosLivres in listaDiarias:
>                                 strDisponibilidade+='<TD>%s</TD>' %
> str(numeroAptosLivres)
>                         strDisponibilidade+='</TR>'
>                 self.template="""       <table border="1">
>                 <TR>
>                         <TD>esq</TD>
>                         <TD>dir</TD>
>                         <TD colspan="30" align="center">MM/AAAA</TD>
>                 </TR>
>                 <TR>
>                         <TD colspan="2" rowspan="2"
> align="center">Tipo Apto</TD>
>                         %s
>                 </TD>
>                 <TR>
>                         %s
>                 </TR>
>                 %s
>         </table>""" % (strDiasSemana, strDiasMes, strDisponibilidade)
>
>
>    When I put it under:
>
>         @expose(template="hotelx.templates.geral", allow_json=True)
>         def SandBox(self, tg_errors = None):
>                 if(tg_errors):
>                         turbogears.flash(u"Erro de validação")
>                 lala = myWidgets.MapaReserva()
>                 return dict(form=lala)
>
>    With a template that has a ${form()}, on that place returns  
> nothing... :(

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to