[EMAIL PROTECTED] wrote:
> Is this a bug in kid or just I'm trying to do something it's not
> supposed to do 

It's a side effect of what you are doing. The self variable is part of
locals. What is happening is that all locals are then fed into
template_util.generate_content, which takes objects and generates obects for
the serialization stream. When it gets self (a BaseTemplate instance) it
tries to serialize it. This in turn tries to serialize locals again...yada,
yada.

Here is an alterate solution:

<?python
def template_locals(template):
    for name, value in template.__dict__.iteritems():
        if not name.startswith('_'):
            yield name, value
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";
xmlns:py="http://purl.org/kid/ns#";>
<head>
<title>Welcome to TurboGears</title>
</head>
<body>
<li py:for="var,val in template_locals(self)">
    <span>${var} = ${val}</span>
</li>
</body>
</html>

Which yields:

In [1]: import kid

In [2]: print kid.Template(file='junk.kid').serialize()
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title>Welcome to TurboGears</title>
</head>
<body />
</html>

In [3]: print kid.Template(file='junk.kid', a=1, b=2).serialize()
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title>Welcome to TurboGears</title>
</head>
<body>
<li>
    <span>a = 1</span>
</li>
<li>
    <span>b = 2</span>
</li>
</body>
</html>

In [4]:

David Stanek

--
http://www.traceback.org



Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
kid-template-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kid-template-discuss

Reply via email to