Kid templates are a PAIN to debug

6 views
Skip to first unread message

Jeremy Jones

unread,
Jan 2, 2006, 4:55:05 PM1/2/06
to turbo...@googlegroups.com
I'm working on the shopping cart for my wife's website (which I'll soon
extract for the community) and keep running into something. When I
modify a piece of session data then hit a specific page again, I get
this error in the browser:


500 Internal error

Server got itself in trouble

Traceback (most recent call last):
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/CherryPy-2.1.0-py2.4.egg/cherrypy/_cphttptools.py", line 271, in run
main()
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/CherryPy-2.1.0-py2.4.egg/cherrypy/_cphttptools.py", line 502, in main
body = page_handler(*args, **cherrypy.request.paramMap)
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/TurboGears-0.9a0dev_r425-py2.4.egg/turbogears/controllers.py", line 242, in newfunc
html, *args, **kw)
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/TurboGears-0.9a0dev_r425-py2.4.egg/turbogears/database.py", line 189, in run_with_transaction
retval = func(*args, **kw)
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/TurboGears-0.9a0dev_r425-py2.4.egg/turbogears/controllers.py", line 262, in _execute_func
return _process_output(tg_format, output, html)
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/TurboGears-0.9a0dev_r425-py2.4.egg/turbogears/controllers.py", line 64, in _process_output
output = view.render(output, tg_format, template=template)
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/TurboGears-0.9a0dev_r425-py2.4.egg/turbogears/view.py", line 56, in render
return engine.render(info, format, fragment, template)
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/TurboGears-0.9a0dev_r425-py2.4.egg/turbogears/kidsupport.py", line 141, in render
return t.serialize(encoding=self.defaultencoding, output=format, fragment=fragment)
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/__init__.py", line 232, in serialize
return serializer.serialize(self, encoding, fragment)
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/serialization.py", line 51, in serialize
text = list(self.generate(stream, encoding, fragment))
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/serialization.py", line 316, in generate
stream = iter(stream)
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/__init__.py", line 257, in __iter__
return iter(self.transform())
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/__init__.py", line 312, in transform
stream = self.pull()
File "/usr/local/apps/python2.4/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/__init__.py", line 271, in pull
self.initialize()
File "/home/jmjones/svn/home/pppweb/trunk/pppwebproject/tg/pppweb/pppweb/templates/view_cart.py", line 19, in initialize
File "/home/jmjones/svn/home/pppweb/trunk/pppwebproject/tg/pppweb/pppweb/templates/master.py", line 21, in initialize
TypeError: 'NoneType' object is not callable


This is a huge pain to debug because .... how can I get at what's going
on? I've tried a suggestion someone posted here of dropping into
IPython through an IPShellEmbed() call. I can call IPShellEmbed() from
within the controller and it shows me what's going on inside the
controller. I've put the same thing in the offending template, but if
the error is occurring inside the template, it never gets called.

I guess I could look at templates/master.py .... oh, that's right - it
doesn't exist. I just googled and didn't find a flag to turn on
generation of .py files from Kid. If someone knows how, I'd appreciate
some insite. I guess I'm about to dig into kid/__init__.py to see if I
can track down more of what's going on... Just thought I'd take a
moment to whine while it's fresh on my frustration list.


- jmj

David Stanek

unread,
Jan 2, 2006, 5:05:57 PM1/2/06
to turbo...@googlegroups.com


On 1/2/06, Jeremy Jones <zane...@bellsouth.net> wrote:

I guess I could look at templates/master.py .... oh, that's right - it
doesn't exist.  I just googled and didn't find a flag to turn on
generation of .py files from Kid.  If someone knows how, I'd appreciate
some insite.  I guess I'm about to dig into kid/__init__.py to see if I
can track down more of what's going on...  Just thought I'd take a
moment to whine while it's fresh on my frustration list.



There is a couple tickets on better error handling already. So it is only a matter of time now. To turn on .py generation just have KID_OUTPUT_PY="true" in your server's environment.

-- David

Jeremy Jones

unread,
Jan 2, 2006, 5:27:33 PM1/2/06
to turbo...@googlegroups.com
OK - I have the .py creation turned on.  Here's the bottom of the traceback again:

  File "/usr/local/apps/python2.4/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/__init__.py", line 314, in transform
    By default, the `pull` method is called to obtain the stream.
  File "/usr/local/apps/python2.4/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/__init__.py", line 273, in pull
    try:
  File "/home/jmjones/svn/home/pppweb/trunk/pppwebproject/tg/pppweb/pppweb/templates/view_cart.py", line 19, in initialize
    rslt = initialize(self)
  File "/home/jmjones/svn/home/pppweb/trunk/pppwebproject/tg/pppweb/pppweb/templates/master.py", line 21, in initialize
    def initialize(self):
TypeError: 'NoneType' object is not callable
Here is some context around line 21 in my master.py:


     14 def initialize(template): pass
     15 doctype = (u'html', u'-//W3C//DTD XHTML 1.0 Transitional//EN', u'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd')
     16 import sitetemplate
     17 from turbogears import identity
     18 from cherrypy import session
     19 class Template(template_util.get_base_class(sitetemplate, __file__),BaseTemplate):
     20     _match_templates = []
     21     def initialize(self):  #<- The exception is happening here because it says that it's not callable
     22         rslt = initialize(self)
     23         if rslt != 0: super(Template, self).initialize()

And here is some context around line 19 in my view_cart.py file:

     13 BaseTemplate = kid.BaseTemplate
     14 def initialize(template): pass
     15 doctype = (u'html', u'-//W3C//DTD XHTML 1.0 Transitional//EN', u'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd')
     16 class Template(template_util.get_base_class('master.kid', __file__),BaseTemplate):
     17     _match_templates = []
     18     def initialize(self):
     19         rslt = initialize(self)
     20         if rslt != 0: super(Template, self).initialize()


Any idea what's going on or where I can look to figure this out?  It's not consistently happening.  It only happens after a certain sequence of events, but not always.

Any help or insight would be greatly appreciated.

- jmj

David Stanek

unread,
Jan 2, 2006, 5:52:39 PM1/2/06
to turbo...@googlegroups.com
Are you possibly using the variable name initialize in the bad cases?

-- David

Michele Cella

unread,
Jan 2, 2006, 6:16:41 PM1/2/06
to TurboGears
Jeremy Jones wrote:
>
> OK - I have the .py creation turned on. Here's the bottom of the
> traceback again:
>
> File "/usr/local/apps/python2.4/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/__init__.py", line 314, in transform
> By default, the `pull` method is called to obtain the stream.
> File "/usr/local/apps/python2.4/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/__init__.py", line 273, in pull
> try:
> File "/home/jmjones/svn/home/pppweb/trunk/pppwebproject/tg/pppweb/pppweb/templates/view_cart.py", line 19, in initialize
> rslt = initialize(self)
> File "/home/jmjones/svn/home/pppweb/trunk/pppwebproject/tg/pppweb/pppweb/templates/master.py", line 21, in initialize
> def initialize(self):
> TypeError: 'NoneType' object is not callable
>

For what is worth I'm experiencing the same bug with the
DataController, it happens after adding/editing one element, the next
operation gives me the same error (NoneType...).

Ciao
Michele

David Stanek

unread,
Jan 2, 2006, 6:22:41 PM1/2/06
to turbo...@googlegroups.com
On 1/2/06, Michele Cella <michel...@gmail.com> wrote:

Jeremy Jones wrote:
>   File "/home/jmjones/svn/home/pppweb/trunk/pppwebproject/tg/pppweb/pppweb/templates/view_cart.py", line 19, in initialize
>     rslt = initialize(self)
>   File "/home/jmjones/svn/home/pppweb/trunk/pppwebproject/tg/pppweb/pppweb/templates/master.py", line 21, in initialize
>     def initialize(self):
> TypeError: 'NoneType' object is not callable
>

For what is worth I'm experiencing the same bug with the
DataController, it happens after adding/editing one element, the next
operation gives me the same error (NoneType...).

Can one of you forward me the offending template and it's ancestors to my email. Once I have an answer I will post it to the list.

-- David

Leandro Lucarella

unread,
Jan 2, 2006, 6:35:14 PM1/2/06
to turbo...@googlegroups.com
David Stanek, el lunes 2 de enero a las 17:05 me escribiste:

I think it would be really nice to add an option for this and have it
activated in the default dev.cfg

--
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
.------------------------------------------------------------------------,
\ GPG: 5F5A8D05 // F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05 /
'--------------------------------------------------------------------'
La máquina de la moneda, mirá como te queda!
-- Sidharta Kiwi

Jeremy Jones

unread,
Jan 2, 2006, 6:45:17 PM1/2/06
to turbo...@googlegroups.com
David Stanek wrote:

> On 1/2/06, *Jeremy Jones* <zane...@bellsouth.net

> <mailto:zane...@bellsouth.net>> wrote:
>
> David Stanek wrote:
>
>>
>>

>> On 1/2/06, *Jeremy Jones* <zane...@bellsouth.net

I just double checked and I don't find any "initialize" variable
anywhere in this app. Thx,

- jmj

Jeremy Jones

unread,
Jan 2, 2006, 8:02:59 PM1/2/06
to turbo...@googlegroups.com
I just svn updated my TG (and third party stuff) and this is working
much better now. I've been hitting the new code for about 15-20 minutes
now and I've seen 0 of the same problem.

Thanks all,

- jmj

Tim Littlemore

unread,
Jan 2, 2006, 8:13:48 PM1/2/06
to turbo...@googlegroups.com
I've got nothing useful to add to this, other than to mention that I am
seeing this problem too. I still haven't figured out the pattern to when
this occurs though, it seems random to me.

Whereabouts do I need to add 'KID_OUTPUT_PY="true"' to generate the .py
files?

I just svn updated earlier today too.

Cheers,
Tim

Jeremy Jones

unread,
Jan 2, 2006, 8:29:06 PM1/2/06
to turbo...@googlegroups.com
Tim Littlemore wrote:

Set an environment variable for it. It worked for me.

- jmj

Kevin Dangoor

unread,
Jan 3, 2006, 11:33:33 AM1/3/06
to turbo...@googlegroups.com
On 1/2/06, Tim Littlemore <t...@tjl2.com> wrote:
> I've got nothing useful to add to this, other than to mention that I am
> seeing this problem too. I still haven't figured out the pattern to when
> this occurs though, it seems random to me.
>
> Whereabouts do I need to add 'KID_OUTPUT_PY="true"' to generate the .py
> files?
>
> I just svn updated earlier today too.

Make sure you don't have any variables with these names:
'content',
'generate',
'initialize',
'pull',
'serialize',
'serializer',
'transform',
'write']

David has some ideas on how to give templates their own namespace but,
for now, these methods defined on BaseTemplate are "using up" those
names.

Kevin

David Stanek

unread,
Jan 4, 2006, 1:05:16 AM1/4/06
to turbo...@googlegroups.com

On 1/3/06, Kevin Dangoor <dan...@gmail.com > wrote:

David has some ideas on how to give templates their own namespace but,
for now, these methods defined on BaseTemplate are "using up" those
names.


This is all being played out in a branch: svn://lesscode.org/kid/branches/sandboxing

-- David

Max Ischenko

unread,
Jan 4, 2006, 7:42:24 AM1/4/06
to TurboGears
Debugging is certainly painful even without TG getting in the way.

The only crude way to debug actual Kid errors so far is a trial-and-run
approach with cutting suspicious blocks of code.

I've documented my experience here:
http://max.textdriven.com/blog/entries/69/debugging-kid-templates-and-leaking-abstractions/

Regards,
Max.

Jeremy Jones

unread,
Jan 4, 2006, 9:20:15 AM1/4/06
to turbo...@googlegroups.com
I'm having quasi-random re-occurrences of this problem again even after
SVN upping last night.

- jmj

Kevin Dangoor

unread,
Jan 4, 2006, 10:19:02 AM1/4/06
to turbo...@googlegroups.com
This is definitely fixable. If it doesn't get tackled before the PyCon
sprint, it will undoubtedly get tackled then.

Kevin


--
Kevin Dangoor
Author of the Zesty News RSS newsreader

email: k...@blazingthings.com
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com

Kevin Dangoor

unread,
Jan 4, 2006, 10:21:09 AM1/4/06
to turbo...@googlegroups.com
On 1/4/06, Jeremy Jones <zane...@bellsouth.net> wrote:
>
> I'm having quasi-random re-occurrences of this problem again even after
> SVN upping last night.

Just to confirm something. I know that initialize was asked about, but
make sure you don't have any of these as variable names:

'content',
'generate',
'initialize',
'pull',
'serialize',
'serializer',
'transform',
'write']

If you have one of these in an if, you might get an error like that
only when the condition is true.

Kevin

Jeremy Jones

unread,
Jan 4, 2006, 10:37:03 AM1/4/06
to turbo...@googlegroups.com
I don't think this is my problem. Here's checking my controllers directory:

jmjones@qiwi 10:29AM pppweb % for phrase in content generate initialize
pull serialize transform write
for> do
for> echo "****************************"
for> echo Checking for $phrase
for> grep $phrase *py
for> echo "****************************"
for> done
****************************
Checking for content
****************************
****************************
Checking for generate
****************************
****************************
Checking for initialize
****************************
****************************
Checking for pull
****************************
****************************
Checking for serialize
tg_store.py: def serialize_details(self):
tg_store.py: element_root = ElementTree.Element("serialized")
tg_store.py: order_item =
model.OrderItem(customer_order=order_id, product=base_id,
quantity=base_quantity, details=cart_item.serialize_details())
****************************
****************************
Checking for transform
****************************
****************************
Checking for write
****************************

The only thing in my controller containing a part of the word is
"serialize", but on anything that should probably cause conflict,
"serialize" is only a piece of some of one of the method names.


Here's checking my templates directory:
jmjones@qiwi 10:31AM templates % for phrase in content generate
initialize pull serialize transform write
do
echo "****************************"
echo Checking for $phrase
grep $phrase *kid
echo "****************************"
done
****************************
Checking for content
do_add_to_cart.kid: <meta content="text/html; charset=UTF-8"
http-equiv="content-type" py:replace="''"/>
form_page.kid: <meta content="text/html; charset=UTF-8"
http-equiv="content-type" py:replace="''"/>
help.kid: <meta content="text/html; charset=UTF-8"
http-equiv="content-type" py:replace="''"/>
master.kid: <meta content="text/html; charset=UTF-8"
http-equiv="content-type" py:replace="''"/>
master.kid: <div id="contents">
master.kid: <div class="flash"
py:content="tg_flash"></div>
master.kid: <!--content-->
master.kid: <td py:content="item[:]" id="main">
master.kid: <!--content-->
registration_successful.kid: <meta content="text/html; charset=UTF-8"
http-equiv="content-type" py:replace="''"/>
****************************
****************************
Checking for generate
****************************
****************************
Checking for initialize
****************************
****************************
Checking for pull
****************************
****************************
Checking for serialize
****************************
****************************
Checking for transform
****************************
****************************
Checking for write
****************************

And I don't see any problems in the "content" stuff above.


- jmj

Kevin Dangoor

unread,
Jan 4, 2006, 1:16:00 PM1/4/06
to turbo...@googlegroups.com
On 1/4/06, Jeremy Jones <zane...@bellsouth.net> wrote:
> Checking for content
> do_add_to_cart.kid: <meta content="text/html; charset=UTF-8"
> http-equiv="content-type" py:replace="''"/>
> form_page.kid: <meta content="text/html; charset=UTF-8"
> http-equiv="content-type" py:replace="''"/>
> help.kid: <meta content="text/html; charset=UTF-8"
> http-equiv="content-type" py:replace="''"/>
> master.kid: <meta content="text/html; charset=UTF-8"
> http-equiv="content-type" py:replace="''"/>
> master.kid: <div id="contents">
> master.kid: <div class="flash"
> py:content="tg_flash"></div>
> master.kid: <!--content-->
> master.kid: <td py:content="item[:]" id="main">
> master.kid: <!--content-->
> registration_successful.kid: <meta content="text/html; charset=UTF-8"
> http-equiv="content-type" py:replace="''"/>
> ****************************

Also in my quest to eliminate the easy stuff: there *was* a bug in Kid
that prevented comments <!-- --> in the master template. This bug was
fixed (tests written, and all of that), but perhaps you've hit upon an
untested case. I don't think that's the problem though.

The error message that you're reporting doesn't seem right.

def initialize(self):

should not give a "NoneType is not callable" error because nothing is
being called on that line. It's a def statement. The *next* line has a
call:

22 rslt = initialize(self)

but how can initialize be None? (I see why David asked if there was a
variable called initialize specifically).

If possible, you may find it instructive to play with those generated
.py files directly from the Python shell.

Kevin

Jeremy Jones

unread,
Jan 4, 2006, 1:45:34 PM1/4/06
to turbo...@googlegroups.com
I'm not going to get my hopes up, but I just removed all comments from
my master.kid file and have been adding and removing items from my
shopping cart and starting and stopping the server and have not seen a
repeat of the misbehavior. I'll report back with any problems.

- jmj

David Stanek

unread,
Jan 4, 2006, 1:53:41 PM1/4/06
to turbo...@googlegroups.com

 Ac

David Stanek

unread,
Jan 4, 2006, 1:55:10 PM1/4/06
to turbo...@googlegroups.com
Too fast an the submit :-(

Actually if you are using the svn version of Kid, do an update and try again. I rolled back my py:match changes until I can nail down what the semantics should be.

David
--
David Stanek
www.roninds.net

Jeremy Jones

unread,
Jan 4, 2006, 5:30:13 PM1/4/06
to turbo...@googlegroups.com
I svn updated and have been running with my master.kid with and without
comments. No problems so far. Thanks, David, for all the quick
responses over the past couple of days.

- jmj

David Stanek wrote:

> Too fast an the submit :-(
>
> Actually if you are using the svn version of Kid, do an update and try
> again. I rolled back my py:match changes until I can nail down what
> the semantics should be.
>
> David
>

> On 1/4/06, *David Stanek* <ron...@gmail.com
> <mailto:ron...@gmail.com>> wrote:
>
>
>
> On 1/4/06, *Kevin Dangoor* < dan...@gmail.com


> <mailto:dan...@gmail.com>> wrote:
>
>
> On 1/4/06, Jeremy Jones <zane...@bellsouth.net

> www.roninds.net <http://www.roninds.net>


Jeremy Jones

unread,
Jan 7, 2006, 11:15:22 AM1/7/06
to turbo...@googlegroups.com
So, maybe I spoke too soon. I'm getting the error again. And I've
removed all XML comments from the offending master.kid (as well as the
template that extends it). I've got the site on Dreamhost now (running
under fastcgi), but haven't seen the problem there....yet.

Ksenia Marasanova

unread,
Jan 7, 2006, 5:12:23 PM1/7/06
to turbo...@googlegroups.com
I

2006/1/7, Jeremy Jones <zane...@bellsouth.net>:


>
> So, maybe I spoke too soon. I'm getting the error again. And I've
> removed all XML comments from the offending master.kid (as well as the
> template that extends it). I've got the site on Dreamhost now (running
> under fastcgi), but haven't seen the problem there....yet.


I am getting this error too, on the same line (21 of master.py). First
few form submits go without problems, than the error appears and stays
there untill I restart the application :(

--
Ksenia

Jeremy Jones

unread,
Jan 7, 2006, 5:23:29 PM1/7/06
to turbo...@googlegroups.com
Ksenia Marasanova wrote:

This is exactly what I'm seeing. It's not on all pages of the
application, although it's not always on the same page. It's just
usually on the same specific page.

- jmj

Michele Cella

unread,
Jan 8, 2006, 3:22:07 PM1/8/06
to TurboGears

Same here with the DataController after the first submit (that goes
well).

Ciao
Michele

Minh Luu

unread,
Jan 8, 2006, 3:39:24 PM1/8/06
to turbo...@googlegroups.com
I also have exactly the same problem with the last files from the svn.

---
ml

David Stanek

unread,
Jan 8, 2006, 3:43:51 PM1/8/06
to turbo...@googlegroups.com
On 1/8/06, Minh Luu <mi...@toll.com.au> wrote:

I also have exactly the same problem with the last files from the svn.

This has to do with the reloading of base templates, but I can't seem to recreate the issue anymore. Still looking though.

-- David

Jeremy Jones

unread,
Jan 8, 2006, 3:57:22 PM1/8/06
to turbo...@googlegroups.com
David Stanek wrote:

>
>
> On 1/8/06, *Minh Luu* <mi...@toll.com.au <mailto:mi...@toll.com.au>>

It's really sporadic with me. I've been running for a couple of hours
now with no problems. Or did you mean that you had made some code
changes that seem to have fixed the problem? If so, I don't mind svn
upping and running it for a while.

- jmj

Michele Cella

unread,
Jan 8, 2006, 8:51:29 PM1/8/06
to TurboGears
Jeremy Jones wrote:

> David Stanek wrote:
> >
> > This has to do with the reloading of base templates, but I can't seem
> > to recreate the issue anymore. Still looking though.
> >
> > -- David
>
> It's really sporadic with me. I've been running for a couple of hours
> now with no problems. Or did you mean that you had made some code
> changes that seem to have fixed the problem? If so, I don't mind svn
> upping and running it for a while.
>

I'm now running the latest svn and my problem (NoneType with the
DataController) has finally gone away (thanks David).

If you update be sure to reinstall the kid plugin (where David checked
the fix) or you will still get the same error (I've just realized
this).

This means (in turbogears/plugins/kid):

python setup.py install (with sudo if you use it)

or (as I've done):

python setup.py develop

with the last method you don't need to reinstall anymore because the
egg points to your local svn checkout.

Thanks again David.

Ciao
Michele

Jeremy Jones

unread,
Jan 8, 2006, 9:19:28 PM1/8/06
to turbo...@googlegroups.com
Michele Cella wrote:
>
>
>
> I'm now running the latest svn and my problem (NoneType with the
> DataController) has finally gone away (thanks David).
>
> If you update be sure to reinstall the kid plugin (where David checked
> the fix) or you will still get the same error (I've just realized
> this).
>
> This means (in turbogears/plugins/kid):
>
> python setup.py install (with sudo if you use it)
>
> or (as I've done):
>
> python setup.py develop
>
> with the last method you don't need to reinstall anymore because the
> egg points to your local svn checkout.
>
> Thanks again David.
>
> Ciao
> Michele
>

I just svn upped and looks like the latest Kid is from Wednesday:

jmjones@qiwi 9:08PM trunk % svn info thirdparty/kid
Path: thirdparty/kid
URL: svn://lesscode.org/kid/trunk
Repository UUID: 2e2b2306-ebee-0310-be8d-abc9dabbc1eb
Revision: 246
Node Kind: directory
Schedule: normal
Last Changed Author: dstanek
Last Changed Rev: 246
Last Changed Date: 2006-01-04 12:22:46 -0500 (Wed, 04 Jan 2006)
Properties Last Updated: 2005-12-25 07:01:14 -0500 (Sun, 25 Dec 2005)

Are you going off of a branch, or the trunk? Looks like what I've got
(rev 246) is newer than any of the branches that are in Kid svn.

- jmj

Alberto

unread,
Jan 9, 2006, 3:55:04 AM1/9/06
to TurboGears
I'm having the same problem too, same kid rev (246) but on line 19:

Here are the last lines of the traceback where control is handled to
the kid:

File
"/usr/lib/python2.4/site-packages/TurboKid-0.9.0-py2.4.egg/turbokid/kidsupport.py",
line 136, in render
return t.serialize(encoding=self.defaultencoding, output=format,
fragment=fragment)
File "/home/alberto/turbogears/thirdparty/kid/kid/__init__.py", line


232, in serialize
return serializer.serialize(self, encoding, fragment)

File "/home/alberto/turbogears/thirdparty/kid/kid/serialization.py",


line 51, in serialize
text = list(self.generate(stream, encoding, fragment))

File "/home/alberto/turbogears/thirdparty/kid/kid/serialization.py",
line 324, in generate
stream = iter(stream)
File "/home/alberto/turbogears/thirdparty/kid/kid/__init__.py", line


257, in __iter__
return iter(self.transform())

File "/home/alberto/turbogears/thirdparty/kid/kid/__init__.py", line


312, in transform
stream = self.pull()

File "/home/alberto/turbogears/thirdparty/kid/kid/__init__.py", line
271, in pull
self.initialize()
File "/home/alberto/lalala/templates/seccion.py", line 19, in
initialize
import sys
File "/home/alberto/lalala/templates/master.py", line 19, in
initialize


TypeError: 'NoneType' object is not callable

I'm willing to help in what is needed to track down this, unfortunately
I know nothing about kid internals so it can only be in the testing
etc.

Thanks,
Alberto

Michele Cella

unread,
Jan 9, 2006, 4:40:55 AM1/9/06
to TurboGears
Jeremy Jones wrote:
>
> I just svn upped and looks like the latest Kid is from Wednesday:
>
> jmjones@qiwi 9:08PM trunk % svn info thirdparty/kid
> Path: thirdparty/kid
> URL: svn://lesscode.org/kid/trunk
> Repository UUID: 2e2b2306-ebee-0310-be8d-abc9dabbc1eb
> Revision: 246
> Node Kind: directory
> Schedule: normal
> Last Changed Author: dstanek
> Last Changed Rev: 246
> Last Changed Date: 2006-01-04 12:22:46 -0500 (Wed, 04 Jan 2006)
> Properties Last Updated: 2005-12-25 07:01:14 -0500 (Sun, 25 Dec 2005)
>
> Are you going off of a branch, or the trunk? Looks like what I've got
> (rev 246) is newer than any of the branches that are in Kid svn.
>

michele@ionic:~/turbogears/plugins$ svn info kid
Path: kid
URL: http://www.turbogears.org/svn/turbogears/trunk/plugins/kid
Repository UUID: 77541ad4-5f01-0410-9ede-a1b63cd9a898
Revision: 483


Node Kind: directory
Schedule: normal
Last Changed Author: dstanek

Last Changed Rev: 477
Last Changed Date: 2006-01-08 16:22:25 +0100 (Sun, 08 Jan 2006)

I was not refering to the Kid repository but to the Kid template plugin
(TurboKid).

See this message for more info:
http://tinyurl.com/asw49

Ciao
Michele

Mike

unread,
Jan 9, 2006, 11:04:36 AM1/9/06
to TurboGears
David,

My problem is fixed now as well with an SVN checkout today. Thanks for
your work on it.

-Mike

Message has been deleted

Mike Sarahan

unread,
Jan 10, 2006, 4:38:03 PM1/10/06
to TurboGears
This problem (or something very much like it) cropped up for me again.

I get it only when trying to access my query methods/templates, not on
any of my "static" methods/templates that just serve as html. Once it
breaks, the static methods remain functional, but none of the dynamic
content templates work anymore.

Here's the first error:

Traceback (most recent call last):
File

"/usr/lib/python2.4/site-packages/CherryPy-2.1.1-py2.4.egg/cherrypy/_cphttptools.py",


line 271, in run
main()
File

"/usr/lib/python2.4/site-packages/CherryPy-2.1.1-py2.4.egg/cherrypy/_cphttptools.py",


line 502, in main
body = page_handler(*args, **cherrypy.request.paramMap)

File "/home/mikez0r/TG0.9/trunk/turbogears/controllers.py", line 240,
in newfunc
html, fragment, *args, **kw)
File "/home/mikez0r/TG0.9/trunk/turbogears/database.py", line 189, in


run_with_transaction
retval = func(*args, **kw)

File "/home/mikez0r/TG0.9/trunk/turbogears/controllers.py", line 262,
in _execute_func
return _process_output(tg_format, output, html, fragment)
File "/home/mikez0r/TG0.9/trunk/turbogears/controllers.py", line 62,


in _process_output
output = view.render(output, tg_format,

template=template,fragment=fragment)
File "/home/mikez0r/TG0.9/trunk/turbogears/view.py", line 57, in


render
return engine.render(info, format, fragment, template)
File

"/usr/lib/python2.4/site-packages/TurboKid-0.9.0-py2.4.egg/turbokid/kidsupport.py",
line 137, in render


return t.serialize(encoding=self.defaultencoding, output=format,
fragment=fragment)
File

"/usr/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/__init__.py",


line 232, in serialize
return serializer.serialize(self, encoding, fragment)
File

"/usr/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/serialization.py",


line 51, in serialize
text = list(self.generate(stream, encoding, fragment))
File

"/usr/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/serialization.py",
line 316, in generate
stream = iter(stream)
File
"/usr/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/__init__.py",


line 257, in __iter__
return iter(self.transform())
File

"/usr/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/__init__.py",


line 312, in transform
stream = self.pull()
File

"/usr/lib/python2.4/site-packages/kid-0.8-py2.4.egg/kid/__init__.py",


line 271, in pull
self.initialize()

File "/var/www/localhost/htdocs/photogal/photogal/templates/rand.py",
line 19, in initialize
File
"/var/www/localhost/htdocs/photogal/photogal/templates/picmenu.py",
line 20, in initialize
File
"/var/www/localhost/htdocs/photogal/photogal/templates/master.py", line


19, in initialize
TypeError: 'NoneType' object is not callable


If I then refresh the page, I get a second error:

Traceback (most recent call last):
File

"/usr/lib/python2.4/site-packages/CherryPy-2.1.1-py2.4.egg/cherrypy/_cphttptools.py",


line 271, in run
main()
File

"/usr/lib/python2.4/site-packages/CherryPy-2.1.1-py2.4.egg/cherrypy/_cphttptools.py",


line 502, in main
body = page_handler(*args, **cherrypy.request.paramMap)

File "/home/mikez0r/TG0.9/trunk/turbogears/controllers.py", line 240,
in newfunc
html, fragment, *args, **kw)
File "/home/mikez0r/TG0.9/trunk/turbogears/database.py", line 189, in


run_with_transaction
retval = func(*args, **kw)

File "/home/mikez0r/TG0.9/trunk/turbogears/controllers.py", line 262,
in _execute_func
return _process_output(tg_format, output, html, fragment)
File "/home/mikez0r/TG0.9/trunk/turbogears/controllers.py", line 62,


in _process_output
output = view.render(output, tg_format,

template=template,fragment=fragment)
File "/home/mikez0r/TG0.9/trunk/turbogears/view.py", line 57, in


render
return engine.render(info, format, fragment, template)
File

"/usr/lib/python2.4/site-packages/TurboKid-0.9.0-py2.4.egg/turbokid/kidsupport.py",
line 123, in render
tclass = self.load_template(template)
File
"/usr/lib/python2.4/site-packages/TurboKid-0.9.0-py2.4.egg/turbokid/kidsupport.py",
line 97, in load_template
mod = _freshen_template(package, basename, tfile, classname)
File
"/usr/lib/python2.4/site-packages/TurboKid-0.9.0-py2.4.egg/turbokid/kidsupport.py",
line 45, in _freshen_template
if _freshen_bases(bases, saved_ctime) or saved_ctime < mtime:
File
"/usr/lib/python2.4/site-packages/TurboKid-0.9.0-py2.4.egg/turbokid/kidsupport.py",
line 23, in _freshen_bases
if _freshen_bases(base.__bases__, saved_ctime):
File
"/usr/lib/python2.4/site-packages/TurboKid-0.9.0-py2.4.egg/turbokid/kidsupport.py",
line 29, in _freshen_bases
mtime = os.stat(sys.modules[modname].__file__).st_mtime
KeyError: 'kid.util.template_0x3E44F9BL'


Tried to fix by getting latest SVN, running python setup.py develop,
and also running python setup.py install in the plugins/kid directory.

Mike Sarahan

unread,
Jan 10, 2006, 6:32:03 PM1/10/06
to TurboGears
All right, things have switched around. I cleaned out all TG-related
folders in my python/site-packages. Updated SVN to 502. Ran python
setup.py develop in my trunk dir.

Now only my dynamic-data templates will load.

Same error message as the first one above, and refreshing this time
only results in the same error, not a different one.

Jared Kuolt

unread,
Jan 10, 2006, 6:38:16 PM1/10/06
to turbo...@googlegroups.com
It's happening for me in latest SVN and with Toasty Goat source,
viewable here: http://toastygoat.org/trac/browser/trunk


--
jared...@gmail.com

Jeremy Jones

unread,
Jan 10, 2006, 9:26:27 PM1/10/06
to turbo...@googlegroups.com
I'm still getting this as well. I just had a breakthrough in my
thinking, though. All my errors (AFAICR) are in master.kid when some
other page extends it. In a clear and desperate violation of the DRY
(Don't Repeat Yourself) principle I've begun to remove master.kid
extending from my site. As well as a breakthrough in my thinking, I've
had a tangible breakthrough in results. I've just been able to
de-funkify a funked up page without restarting the TG server by doing
so. So, removing the reference to master.kid in the funked up page
cleared up the page without having to restart. I'm going to try this on
more pages and see if it helps.

Eh. Maybe my hack isn't *too* much of a violation of DRY since I am
doing <div py:content="document('header_extracted_from_master.kid)"></div>
and the same with the footer.

- jmj

nerkles

unread,
Jan 11, 2006, 10:45:17 PM1/11/06
to TurboGears
Any update on this problem? I've got a pretty bad case of it.

Kevin Dangoor

unread,
Jan 12, 2006, 10:44:14 AM1/12/06
to turbo...@googlegroups.com
On 1/11/06, nerkles <ner...@gmail.com> wrote:
>
> Any update on this problem? I've got a pretty bad case of it.

Make sure you're running the latest rev of Kid, TurboKid and
TurboGears. The recent reports seem to be positive.

Kevin

--
Kevin Dangoor
Author of the Zesty News RSS newsreader

email: k...@blazingthings.com
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com

nerkles

unread,
Jan 12, 2006, 11:05:41 AM1/12/06
to TurboGears
Yes, thanks. Updated to the latest of everything, and also created a
new empty quickstarted app, and carefully brought my code in, keeping
as many defaults of the new empty app as possible. So far the problem
seems to be gone, and performance seems a little snappier too. :D

Jared Kuolt

unread,
Jan 12, 2006, 1:51:27 PM1/12/06
to turbo...@googlegroups.com
TG r506 and TurboKid 0.9 - still having this problem.


--
jared...@gmail.com

Kevin Dangoor

unread,
Jan 12, 2006, 2:09:35 PM1/12/06
to turbo...@googlegroups.com
and you have the latest rev of Kid as well? If so, that's a bummer.

Kevin

Jared Kuolt

unread,
Jan 12, 2006, 2:14:27 PM1/12/06
to turbo...@googlegroups.com
Kid == r251. Is that wrong?


--
jared...@gmail.com

Mike Sarahan

unread,
Jan 12, 2006, 3:31:07 PM1/12/06
to TurboGears
Jared,

Mine cleared up - can't really explain why. I noticed that after
wiping out all TG-related eggs in site-packages, then re-running python
setup.py develop in trunk, then running python setup.py install in
plugins/kid, it worked for a little while. So whenever it would break,
I'd just go through that process. I keep on expecting it to break
again, but it's been running smoothly for a couple of days now, despite
my best efforts.

Mike

Jeremy Jones

unread,
Jan 12, 2006, 3:42:00 PM1/12/06
to turbo...@googlegroups.com
Mine would do the same thing. I didn't go to the drastic measures of
wiping my TG related eggs, though. Mine is working great on everything
but the few straggling pages that extend master.kid. Every time I get
the error on a page, I just take out the py:extends="master.kid" (or
whatever the syntax is) and manually put the pertinent stuff in the
page. It's a pain, I know, but I have not yet had a single error on a
non-extended page. I would not consider this a long-term, workaround,
though. I think this needs to be confidently fixed.

- jmj

Kevin Dangoor

unread,
Jan 12, 2006, 4:27:51 PM1/12/06
to turbo...@googlegroups.com
On 1/12/06, Jeremy Jones <zane...@bellsouth.net> wrote:
> Mine would do the same thing. I didn't go to the drastic measures of
> wiping my TG related eggs, though. Mine is working great on everything
> but the few straggling pages that extend master.kid. Every time I get
> the error on a page, I just take out the py:extends="master.kid" (or
> whatever the syntax is) and manually put the pertinent stuff in the
> page. It's a pain, I know, but I have not yet had a single error on a
> non-extended page. I would not consider this a long-term, workaround,
> though. I think this needs to be confidently fixed.

py;extends="'master.kid'" functions very differently from
py:extends="sitetemplate" (the single quotes have Kid go hunting
around for the template, whereas the sitetemplate way without the
quotes refers directly to a module available in your template module's
namespace). So, maybe there does remain some issue there.

Kevin

Mike Sarahan

unread,
Jan 12, 2006, 11:58:38 PM1/12/06
to TurboGears
Jeremy,

I haven't removed any master extensions. Still no errors today... I'll
certainly post here if I encounter one.

-Mike

Reply all
Reply to author
Forward
0 new messages