[TurboGears] Re: kid drives me crazy

2006-10-31 Thread Sylvain Hellegouarch


 *** It would have been pretty stupid for me to start, if someone else
 was already doing it, don't you think? :-)

I much agree. Let's say I had not read your message like that ;)


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



[TurboGears] Re: kid drives me crazy

2006-10-31 Thread Kevin Dangoor

On Oct 31, 2006, at 2:52 AM, Stuart Clarke wrote:


 Is anyone planning to write a memcached caching mechanism for  
 Genshi?

 I love the whole templates are correct XHTML and editable in  
 insert
 name of favourite web editor here factor.  But until I can  
 memcached
 from these templating systems, I'll be using Cheetah.


 er. Why don't you undertake that task then? :)

 *** It would have been pretty stupid for me to start, if someone else
 was already doing it, don't you think? :-)

You might check on the Genshi list. Also, check out MyghtyUtils (and  
possibly Beaker) which support memcached already.

Kevin

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



[TurboGears] Re: kid drives me crazy

2006-10-31 Thread Karl Guertin

On 10/31/06, Kevin Dangoor [EMAIL PROTECTED] wrote:
 You might check on the Genshi list. Also, check out MyghtyUtils (and
 possibly Beaker) which support memcached already.

If someone is working on memcached support on the Genshi list, they
certainly  haven't announced it.

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



[TurboGears] Re: kid drives me crazy

2006-10-31 Thread Stuart Clarke

Cool.  I should be able to get to it in a couple weeks.

Stuart


On Tue, 2006-10-31 at 10:21 -0500, Karl Guertin wrote:
 On 10/31/06, Kevin Dangoor [EMAIL PROTECTED] wrote:
  You might check on the Genshi list. Also, check out MyghtyUtils (and
  possibly Beaker) which support memcached already.
 
 If someone is working on memcached support on the Genshi list, they
 certainly  haven't announced it.
 
  
 


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



[TurboGears] Re: kid drives me crazy

2006-10-30 Thread Stuart Clarke

Is anyone planning to write a memcached caching mechanism for Genshi?

I love the whole templates are correct XHTML and editable in insert
name of favourite web editor here factor.  But until I can memcached
from these templating systems, I'll be using Cheetah.

Stuart


On Mon, 2006-10-30 at 11:19 -0600, isaac wrote:
 Genshi rocks, I'm using it for everything now (the 0.3.x stable branch
 from svn). Converting the templates is not hard... it's several X
 faster, and it actually tells you what line# in your template is
 causing a problem.
 
 Kid has its strengths, but Genshi is wy better, IMO. I've yet to
 hear of a downside to switching, aside from the small amount of work
 to convert existing templates.
 
 The difficulty of debugging kid templates is a huge pain, and probably
 a very discouraging experience for newbies.
 
 --i
 
  
 
-- 
Stuart Clarke [EMAIL PROTECTED]


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



[TurboGears] Re: kid drives me crazy

2006-10-30 Thread Sylvain Hellegouarch


 Is anyone planning to write a memcached caching mechanism for Genshi?

 I love the whole templates are correct XHTML and editable in insert
 name of favourite web editor here factor.  But until I can memcached
 from these templating systems, I'll be using Cheetah.


er. Why don't you undertake that task then? :)

- Sylvain

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



[TurboGears] Re: kid drives me crazy

2006-10-28 Thread Christoph Zwerschke

Karl Guertin wrote:
 On 10/27/06, Michael Steinfeld [EMAIL PROTECTED] wrote:
 Thanks to both you guys for the help and patience. I am sure I will ask more
 questions in the furture :)

 Chris, Is there more documentation on using itertools.chain() somewhere?
 
 itertools is an official module, docs are available on python.org

... or in the manual that comes with your Python installation.
On the upper right corner you have a link to the Module index.

...or you can always do the following:

import itertools
help(itertools.docs)

... or you can use the Module browser that is also part of the Python 
installation.

The advantage of the latter two methods is that they give you 
information for all installed modules, e.g. TurboGears or Kid.

-- Chris

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



[TurboGears] Re: kid drives me crazy

2006-10-28 Thread Michael Steinfeld
so if I was to do something likeimport calendar, itertoolsmonth = calendar.monthcalendar(2006, 10)days = [i for i in itertools.chain(*month)]if days ==0: print 'td class='in'/td
else: print 'td class='out' days /tdwhat would be the 'correct' and 'most efficient' way to do that using kid? And is there any benefit using a widget?-- -mike


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


[TurboGears] Re: kid drives me crazy

2006-10-28 Thread Karl Guertin

On 10/28/06, Michael Steinfeld [EMAIL PROTECTED] wrote:
 so if I was to do something like

 import calendar, itertools

 month = calendar.monthcalendar(2006, 10)
 days =  [i for i in itertools.chain(*month)]

 if days ==0:
 print 'td class='in'/td
 else:
 print 'td class='out' days /td

 what would be the 'correct' and 'most efficient' way to do that using kid?

That code has a number of errors, but assuming you're passing in the
variable days and guessing what you're shooting for, I'd do:

div py:strip=True py:for=day in days
td class=${day and 'out' or 'in'}${day or ''}/td
/div

If you're not passing in days, get yourself to days in a ?python ? block.

 And is there any benefit using a widget?

Not really.

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



[TurboGears] Re: kid drives me crazy

2006-10-28 Thread Nevyn


Christoph Zwerschke wrote:
 Michael Steinfeld wrote:
  I don't know .. is it just me to spend more time trying to get thing
  done with kid templates then working with turbogears?
  I have a project that has been a lot of fun to working except for kid,
  it occupies the majority of my team and delays my project completion.

 I don't think it is so bad. The good thing about Kid is that you can
 keep all the features easily in memory because they are so few. And once
 you understood the concepts and got accustomed to some typical idioms,
 it's pretty easy.

 The main problem is the bad error reporting of Kid due to the fact that
 Kid templates are converted to Python modules, and the information about
 the position in the XML file gets lost in this process. Genshi processes
 the templates directly, so it is able to give much better error
 reporting. Anyway, Kid is constantly improving and I'm sure we will
 finally have reasonable error reporting in Kid as well.

 Concerning your example where you wanted to do this:

 for data in d:
  if data == 0:
  print td class='lightsout'/td
  else:
 print  td class='lightson' data /td

 This is how you would do it in Kid:

 td py:for=data in d
  class=${data=='0' and 'lightsout' or 'lightson'}
  span py:if=data!='0' py:content=data py:strip=True/
 /td

 However, there is another advice: Preprocess your data before you pass
 it to Kid. Either in a separate ?python ... ? block or completely
 outside the template, in the controller. The Kid template is not the
 place for application logic etc. If the data is preprocessed, everything
 becomes much simpler. E.g. in this case:

 ?python d = [
   data == '0' and ('lightsout', '') or ('lightson', data)
   for data in d] ?
 td py:for=cls, out in d class=$cls py:content=out/
 
 Hope that helps.
 
 -- Christoph


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



[TurboGears] Re: kid drives me crazy

2006-10-28 Thread Bob Ippolito

On 10/28/06, Christoph Zwerschke [EMAIL PROTECTED] wrote:

 Michael Steinfeld wrote:
  so if I was to do something like
 
  import calendar, itertools
 
  month = calendar.monthcalendar(2006, 10)
  days =  [i for i in itertools.chain(*month)]

 You don't need to build a list here; simply pass the iterator.


and if you were to build a flattened list from an iterator of
iterators, the sane way would be much different..

month = calendar.monthcalendar(2006, 10)
days = [day for week in month for day in week]

or imperatively:

month = calendar.monthcalendar(2006, 10)
days = []
for week in month:
days.extend(week)

-bob

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



[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Ian Wilson

Hello hello,
I think kid was chosen because it was the best at the time but now
I think there was talk about moving to Genshi.  I agree with you, kid
takes pretty much 70% of my time.  Debugging it is nearly impossible
so it comes down to needing to memorize the error codes once you
figure out what went wrong after a few hours of moving things around.

Now to address your problem I would try something like this
td py:for=data in d
span py:if=data=='0' py:strip=''br//span
span py:if=data!='0' py:strip=''${data}/span
/td

And the py:strip should get rid of the span tags in the final output
so they aren't taking up preciuos page size.
-Ian

On 10/27/06, Michael Steinfeld [EMAIL PROTECTED] wrote:
 I don't know .. is it just me to spend more time trying to get thing done
 with kid templates then working with turbogears?
 I have a project that has been a lot of fun to working except for kid, it
 occupies the majority of my team and delays my project completion.

 If I was a bully, I would beat that kid up!

 Anyhow, I am simply trying to do a simple if/else statement and it is
 driving me mad. I need your guys help. What would be the best way to do it?

 Python Code I am converting:

 if data = 0:
print td class='lightsout'/td
 else:
print  td class='lightson' data /td


 kid template code


  tr py:for=d in results
   td py:for=data in d
  ${data}

 actually, easier said.. I am trying to replace all occurrences of string 0
 with an empty string 

 I have read the kid docs but they seem to be pretty brief and missing a lot
 of helpful information.

 thanks in advance.



 --
 -mike


  


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



[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Jorge Godoy

Michael Steinfeld [EMAIL PROTECTED] writes:

 I don't know .. is it just me to spend more time trying to get thing done 
 with kid
 templates then working with turbogears?
 I have a project that has been a lot of fun to working except for kid, it 
 occupies the
 majority of my team and delays my project completion.
 If I was a bully, I would beat that kid up!
 Anyhow, I am simply trying to do a simple if/else statement and it is driving 
 me mad. I
 need your guys help. What would be the best way to do it?
 Python Code I am converting:
 if data = 0:
    print td class='lightsout'/td
 else:
    print  td class='lightson' data /td
 kid template code
  tr py:for=d in results
   td py:for=data in d
      ${data}
 actually, easier said.. I am trying to replace all occurrences of string 0 
 with an empty
 string 
 I have read the kid docs but they seem to be pretty brief and missing a lot 
 of helpful
 information.
 thanks in advance.   

Solution 1:

?python
  if data == '0':
 data = ''
?

Solution 2:

span py:strip='1' py:if='data == 0'/span
span py:strip='1' py:if='data != 0'${data}/span

You can write more on your own...

-- 
Jorge Godoy  [EMAIL PROTECTED]

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



[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Michael Steinfeld
Now to address your problem I would try something like thistd py:for="" in d
span py:if=data="" py:strip=''br//spanspan py:if=data!='0' py:strip=''${data}/span/tdAnd the py:strip should get rid of the span tags in the final output
so they aren't taking up preciuos page size.-IanThanks Ian, this seems not to work :( Here is my code tr tr py:for="" in monthcal td py:for="" in days
 span py:if=day=='0' py:strip=''br//span span py:if=day!='0' py:strip=''${day}/span /td /tr
 /trIt's seems quite ridiculous to create control flow like this, almost absurd.here is my code that I am converting, Hopefully you can offer another suggestion for days in self.getMonthCal
(): for day in days: if day == 0: print 'td bgcolor=ee/td' else: print 'td bgcolor=#29558D align=middle'
 print 'a class=links href=""> print '/td'The style is not such concern, above python code works perfect in my CGI, I just can't get it to work in .kid
thanks again.On 10/27/06, Michael Steinfeld 
[EMAIL PROTECTED] wrote: I don't know .. is it just me to spend more time trying to get thing done with kid templates then working with turbogears? I have a project that has been a lot of fun to working except for kid, it
 occupies the majority of my team and delays my project completion. If I was a bully, I would beat that kid up! Anyhow, I am simply trying to do a simple if/else statement and it is
 driving me mad. I need your guys help. What would be the best way to do it? Python Code I am converting: if data = "">print td class='lightsout'/td
 else:printtd class='lightson' data /td kid template codetr py:for="" in results td py:for="" in d
${data} actually, easier said.. I am trying to replace all occurrences of string 0 with an empty string  I have read the kid docs but they seem to be pretty brief and missing a lot
 of helpful information. thanks in advance. -- -mike-- -mike

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


[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Christoph Zwerschke

Michael Steinfeld wrote:
  I don't know .. is it just me to spend more time trying to get thing
  done with kid templates then working with turbogears?
  I have a project that has been a lot of fun to working except for kid,
  it occupies the majority of my team and delays my project completion.

I don't think it is so bad. The good thing about Kid is that you can 
keep all the features easily in memory because they are so few. And once 
you understood the concepts and got accustomed to some typical idioms, 
it's pretty easy.

The main problem is the bad error reporting of Kid due to the fact that 
Kid templates are converted to Python modules, and the information about 
the position in the XML file gets lost in this process. Genshi processes 
the templates directly, so it is able to give much better error 
reporting. Anyway, Kid is constantly improving and I'm sure we will 
finally have reasonable error reporting in Kid as well.

Concerning your example where you wanted to do this:

for data in d:
 if data == 0:
 print td class='lightsout'/td
 else:
print  td class='lightson' data /td

This is how you would do it in Kid:

td py:for=data in d
 class=${data=='0' and 'lightsout' or 'lightson'}
 span py:if=data!='0' py:content=data py:strip=True/
/td

However, there is another advice: Preprocess your data before you pass 
it to Kid. Either in a separate ?python ... ? block or completely 
outside the template, in the controller. The Kid template is not the 
place for application logic etc. If the data is preprocessed, everything 
becomes much simpler. E.g. in this case:

?python d = [
data == '0' and ('lightsout', '') or ('lightson', data)
for data in d] ?
td py:for=cls, out in d class=$cls py:content=out/

Hope that helps.

-- Christoph

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



[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Christoph Zwerschke

Michael Steinfeld wrote:
 I don't know .. is it just me to spend more time trying to get thing 
 done with kid templates then working with turbogears?
 I have a project that has been a lot of fun to working except for kid, 
 it occupies the majority of my team and delays my project completion.

I don't think it is so bad. The good thing about Kid is that you can 
keep all the features easily in memory because they are so few. And once 
you understood the concepts and got accustomed to some typical idioms, 
it's pretty easy.

The main problem is the bad error reporting of Kid due to the fact that 
Kid templates are converted to Python modules, and the information about 
the position in the XML file gets lost in this process. Genshi processes 
the templates directly, so it is able to give much better error 
reporting. Anyway, Kid is constantly improving and I'm sure we will 
finally have reasonable error reporting in Kid as well.

Concerning your example where you wanted to do this:

for data in d:
 if data == 0:
 print td class='lightsout'/td
 else:
print  td class='lightson' data /td

This is how you would do it in Kid:

td py:for=data in d
 class=${data=='0' and 'lightsout' or 'lightson'}
 span py:if=data!='0' py:content=data py:strip=True/
/td

However, there is another advice: Preprocess your data before you pass 
it to Kid. Either in a separate ?python ... ? block or completely 
outside the template, in the controller. The Kid template is not the 
place for application logic etc. If the data is preprocessed, everything 
becomes much simpler. E.g. in this case:

?python d = [
data == '0' and ('lightsout', '') or ('lightson', data)
for data in d] ?
td py:for=cls, out in d class=$cls py:content=out/

Hope that helps.

-- Christoph



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



[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Michael Steinfeld
Duh, right after I clicked send I saw the mistake. don't need to put quotes around '0' and it works.however it screws up my layout but I don't know why it screw up my table cells. Argh.. !! kid is a pain, I don't know Geshi, but hopefully it won't hurt as much.
On 10/27/06, Michael Steinfeld [EMAIL PROTECTED] wrote:
Now to address your problem I would try something like this
td py:for="" in d
span py:if=data="" py:strip=''br//spanspan py:if=data!='0' py:strip=''${data}/span/tdAnd the py:strip should get rid of the span tags in the final output
so they aren't taking up preciuos page size.-IanThanks Ian, this seems not to work :( Here is my code tr tr py:for="" in monthcal
 td py:for="" in days
 span py:if=day=='0' py:strip=''br//span span py:if=day!='0' py:strip=''${day}/span /td /tr
 /trIt's seems quite ridiculous to create control flow like this, almost absurd.here is my code that I am converting, Hopefully you can offer another suggestion for days in 
self.getMonthCal
(): for day in days: if day == 0: print 'td bgcolor=ee/td' else: print 'td bgcolor=#29558D align=middle'
 print 'a class=links href=""> print '/td'The style is not such concern, above python code works perfect in my CGI, I just can't get it to work in .kid
thanks again.
On 10/27/06, Michael Steinfeld 
[EMAIL PROTECTED] wrote: I don't know .. is it just me to spend more time trying to get thing done
 with kid templates then working with turbogears? I have a project that has been a lot of fun to working except for kid, it
 occupies the majority of my team and delays my project completion. If I was a bully, I would beat that kid up! Anyhow, I am simply trying to do a simple if/else statement and it is
 driving me mad. I need your guys help. What would be the best way to do it? Python Code I am converting: if data = "">print td class='lightsout'/td
 else:printtd class='lightson' data /td kid template codetr py:for="" in results td py:for="" in d
${data} actually, easier said.. I am trying to replace all occurrences of string 0 with an empty string  I have read the kid docs but they seem to be pretty brief and missing a lot
 of helpful information. thanks in advance. -- -mike-- -mike

-- -mike

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


[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Bob Ippolito

On 10/27/06, Michael Steinfeld [EMAIL PROTECTED] wrote:
 Duh, right after I clicked send I saw the mistake. don't need to put quotes
 around '0' and it works.

In other words, it helps to pose the question correctly if you want to
get correct suggestions!

 however it screws up my layout but I don't know why it screw up my table
 cells. Argh.. !! kid is a pain, I don't know Geshi, but hopefully it won't
 hurt as much.

Genshi wouldn't really be much different in this case. You just need
to understand how DOM-based templating is supposed to work. One bonus
is that your output HTML will be much cleaner (because it has to be,
in order to be a valid template). Ideally you should modernize the
rest of it (use css and classes instead of old school bgcolor, align,
etc.)

This should be a literal translation, which is ugly, but would be much
less ugly using classes:

td py:for=day in days py:attrs=day and {'bgcolor': '#29558D',
'align': 'middle'} or {'bgcolor': '#ee'}
a class=links href=day.py?day=${day} py:if=day${day}/a
/td

-bob

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



[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Ian Wilson

Yeah since python has types i figured you had the zero as a string.
If the day is an integer its way easier.  You can just do this:
newDay = (day and str(day)) or ''
Since 0 evaluates to False it will move and try the second value which
should be returned.

But that isn't exactly what you are doing since you need something
completely different displayed in each case.

I think you need something in a table cell for the background color to
show up.  If ha that is what you mean by screwing up your layout.
Don't try to put spaces in there using entities... (trust me).  I
usually put the br/ in there for that reason.

The missing elif and else statements is _really_ annoying I think
genshi will fix that as well.  I guess the ideas around kid are good
its just not very smooth around the edges.  The whole system(TG) beats
using php and to me that is all that matters because php makes me want
to lay down on a highway.

-Ian



On 10/27/06, Michael Steinfeld [EMAIL PROTECTED] wrote:
 Duh, right after I clicked send I saw the mistake. don't need to put quotes
 around '0' and it works.

 however it screws up my layout but I don't know why it screw up my table
 cells. Argh.. !! kid is a pain, I don't know Geshi, but hopefully it won't
 hurt as much.



 On 10/27/06, Michael Steinfeld [EMAIL PROTECTED] wrote:
 
 
 
  
   Now to address your problem I would try something like this
   td py:for=data in d
   span py:if=data=='0' py:strip=''br//span
   span py:if=data!='0' py:strip=''${data}/span
   /td
  
   And the py:strip should get rid of the span tags in the final output
   so they aren't taking up preciuos page size.
   -Ian
 
 
  Thanks Ian, this seems not to work :( Here is my code
 
  tr
  tr py:for=days in monthcal
  td py:for=day in days
  span py:if=day=='0' py:strip=''br//span
span py:if=day!='0' py:strip=''${day}/span
  /td
  /tr
  /tr
 
  It's seems quite ridiculous to create control flow like this, almost
 absurd.
 
  here is my code that I am converting, Hopefully you can offer another
 suggestion
 
   for days in self.getMonthCal ():
  for day in days:
  if day == 0:
  print 'td bgcolor=ee/td'
  else:
  print 'td  bgcolor=#29558D align=middle'
  print 'a class=links
 href=day.py?day='+str(day)+''+str(day)+'/a'
  print '/td'
 
  The style is not such concern, above python code works perfect in my CGI,
 I just can't get it to work in .kid
 
  thanks again.
 
 
 
 
 
 
 
 
 
 
 
 
 
   On 10/27/06, Michael Steinfeld  [EMAIL PROTECTED] wrote:
I don't know .. is it just me to spend more time trying to get thing
 done
with kid templates then working with turbogears?
I have a project that has been a lot of fun to working except for kid,
 it
occupies the majority of my team and delays my project completion.
   
If I was a bully, I would beat that kid up!
   
Anyhow, I am simply trying to do a simple if/else statement and it is
driving me mad. I need your guys help. What would be the best way to
 do it?
   
Python Code I am converting:
   
if data = 0:
   print td class='lightsout'/td
else:
   print  td class='lightson' data /td
   
   
kid template code
   
   
 tr py:for=d in results
  td py:for=data in d
 ${data}
   
actually, easier said.. I am trying to replace all occurrences of
 string 0
with an empty string 
   
I have read the kid docs but they seem to be pretty brief and missing
 a lot
of helpful information.
   
thanks in advance.
   
   
   
--
-mike
   
   
 
   
  
  
  
  
 
 
 
  --
  -mike
 
 



 --
 -mike


  


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



[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Christoph Zwerschke

Michael Steinfeld wrote:
 here is my code that I am converting, Hopefully you can offer another 
 suggestion
 
  for days in self.getMonthCal ():
 for day in days:
 if day == 0:
 print 'td bgcolor=ee/td'
 else:
 print 'td  bgcolor=#29558D align=middle'
 print 'a class=links 
 href=day.py?day='+str(day)+''+str(day)+'/a'
 print '/td'
 

Again, make two steps. First preprocess the data:

?python data = [day == 0
 and ('#ee', None, None) or ('#29558d', 'middle', day)
 for days in monthcal for day in days] ?

Then display the data:

td py:for=c, a, d in data bgcolor=$c align=$a
a py:if=d class=links href=day.py?day=$d$d/a/td

This division simplifies a lot. You can also run the preprocessing 
outside the Kid template where it is easier to debug.

-- Christoph

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



[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Christoph Zwerschke

Bob is right in saying that using CSS makes these things much easier and 
cleaner. Michael's then look something like this:



html xmlns:py=http://purl.org/kid/ns#;
head
style
#cal td.first {
 width: 2em;
 background-color: #ee;
}
#cal td.next {
 width: 3em;
 background-color: #29558d;
 text-align: center;
 vertical-align: middle;
}
#cal td.next a {
 color: white;
}
/style
/head
body
table id=caltr
td py:for=day in days class=${day==0 and 'first' or 'next'}
a class=links href=day.py?day=$day py:if=day$day/a/td
/tr/table
/body
/html



The big advantage is that you can play around with different styles 
without breaking your html or your Python code.

BTW, instead of the nested loop, you can pass days as:
days = itertools.chain(*monthcal)

-- Christoph

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



[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Christoph Zwerschke

Michael Steinfeld wrote:
 well, I base my inexperience and frustration with kid on the 
 documentation I suppose. I have been using
 
 http://www.kid-templating.org/language.html
 
 But I have not found it to be all that helpful.

Because that's a refence document only, not a tutorial. Unfortunately, 
nobody has so far written a good tutorial for Kid (or Genshi). At least 
you'll find some Recipes and Examples on http://kid-templating.org.

-- Chris

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



[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Michael Steinfeld
Thanks to both you guys for the help and patience. I am sure I will ask more questions in the furture :)Chris, Is there more documentation on using itertools.chain() somewhere?Mike
On 10/27/06, Christoph Zwerschke [EMAIL PROTECTED] wrote:
Michael Steinfeld wrote: well, I base my inexperience and frustration with kid on the documentation I suppose. I have been using http://www.kid-templating.org/language.html
 But I have not found it to be all that helpful.Because that's a refence document only, not a tutorial. Unfortunately,nobody has so far written a good tutorial for Kid (or Genshi). At least
you'll find some Recipes and Examples on http://kid-templating.org.-- Chris-- -mike

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


[TurboGears] Re: kid drives me crazy

2006-10-27 Thread Karl Guertin

On 10/27/06, Michael Steinfeld [EMAIL PROTECTED] wrote:
 Thanks to both you guys for the help and patience. I am sure I will ask more
 questions in the furture :)

 Chris, Is there more documentation on using itertools.chain() somewhere?

itertools is an official module, docs are available on python.org

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