Solved

Simple conditional in Kid template used with CherryPy

Posted on 2010-08-25
6
408 Views
Last Modified: 2012-05-10
I'm very new to CherryPy, but managed to get it running on FreeBSD.  Working great.  I started using the Kid template, as it is easier to implement than Cheetah, and I need only very basic functionality.  However, I've been unable to get any conditional (py:if) to work within the template.  Or more to the point, every conditional defaults to true apparently, or more likely the conditional is just not processed whatsoever.  

I've used the example from the following, but it doesn't work.....even if I may 5*6=2, it still shows the text.  http://kid-templating.org/language.html#conditionals-py-if

Any hints as to where I might be going wrong or if perhaps there is some configuration thing I need to do?
0
Comment
Question by:Xerc
  • 4
  • 2
6 Comments
 
LVL 16

Assisted Solution

by:gelonida
gelonida earned 500 total points
ID: 33524371
I don't know cherrpy and Kid template, but my suspicion is:


Use
if="5 * 6 == 2"

instead of
if="5*6 = 2"


== is used for comparisons
= should cause an error


0
 

Author Comment

by:Xerc
ID: 33524667
Sorry.  That was my typo in the question.  I double checked.  I did have comparison evaluator of == used.  

This is what I have in my template:   <p py:if="5 * 9 == 25">Math</p>  According to my understanding of Kid, "Math" should not be rendered / shown as 5 x 9 does not equal 25.  But it always shows up.  The Kid example from the page above is:  

<p py:if="5 * 5 == 25"> Python seems to be handling multiplication okay.</p>

I don't get how my syntax is different.

What's weird is that it appears Kid just isn't recognizing the py: portion, as when I look at the page source, py:if="5 * 9 == 25" appears within the <p> tag.  I know the Kid template otherwise works, as I'm passing it variables from CherryPy apps.  Very weird.
0
 
LVL 16

Expert Comment

by:gelonida
ID: 33524696
could you please lookwhat your web browser sees?
view the document as source.

What do you see?

DO you see:
<p py:if="5 * 9 == 25">Math</p>

or do you see?
<p>Math</p>
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 16

Accepted Solution

by:
gelonida earned 500 total points
ID: 33524713
The question why I am asking is:
Do you have any proof, that kid-template is really running and active?

Do you have anything working from kids template (except passing code through tpo the browser)?

0
 
LVL 16

Expert Comment

by:gelonida
ID: 33524775
apologies Xerc

I should have read your reply in more detail. :-(


Does the example in the synopsis work?
(the one which should display the fruits)


0
 

Author Comment

by:Xerc
ID: 33525144
Ah.....I figured out the error.  In my one test template, I messed up the namespace which is associated with the py prefix.  I had xmlns:py="http://perl.org/kid/ns#".  To work it needs to be the correct ns of xmlns:py="http://purl.org/kid/ns#"  Very goof error on my part.  Perhaps a slip and wish to use Perl.  Heh.  
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Python Encoding Problem \u2013 4 114
How to scan rdp  ''only'' open port 3333? 5 117
How can I do this in Pyhton? 12 125
Python 3.5: SQL Results to CSV dump 8 55
Installing Python 2.7.3 version on Windows operating system For installing Python first we need to download Python's latest version from URL" www.python.org " You can also get information on Python scripting language from the above mentioned we…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question