initialize / NoneType not callable bug

6 views
Skip to first unread message

Ben Sizer

unread,
Feb 9, 2007, 8:01:55 PM2/9/07
to TurboGears
I notice this problem has come up many times in the past, but I didn't
see a proper resolution for it.

Basically, after editing templates I sometimes get an error looking
like this:

[...Numerous other lines elided...]
File "f:\code\python24\lib\site-packages\kid-0.9.4-py2.4.egg\kid
\serialization.py", line 109, in serialize
text = ''.join(tuple(
File "f:\code\python24\lib\site-packages\kid-0.9.4-py2.4.egg\kid
\serialization.py", line 622, in generate
stream = iter(stream)
File "f:\code\python24\lib\site-packages\kid-0.9.4-py2.4.egg\kid
\__init__.py", line 309, in __iter__
return iter(self.transform())
File "f:\code\python24\lib\site-packages\kid-0.9.4-py2.4.egg\kid
\__init__.py", line 364, in transform
stream = self.pull()
File "f:\code\python24\lib\site-packages\kid-0.9.4-py2.4.egg\kid
\__init__.py", line 323, in pull
self.initialize()
File "F:\code\pyprojects\whatever\whatever\templates\users.py", line
23, in initialize
File "F:\code\pyprojects\whatever\whatever\templates\master.py",
line 23, in initialize
TypeError: 'NoneType' object is not callable

Usually restarting the server makes the problem go away, at least
until the next time.

I don't think upgrading is the solution; I have tg 1.0.1, and kid
0.9.4 which is already 1 step newer than the one on the TG site
(though apparently 1 older than the current version).

Is there a fix for this sort of problem? If not, I'm not too averse to
migrating to a different template library, if that is the only way to
prevent this sort of thing.

--
Ben Sizer

Christoph Zwerschke

unread,
Feb 10, 2007, 1:47:05 AM2/10/07
to turbo...@googlegroups.com
Ben Sizer wrote:
> I notice this problem has come up many times in the past, but I didn't
> see a proper resolution for it.
> ... TypeError: 'NoneType' object is not callable

> Usually restarting the server makes the problem go away, at least
> until the next time.
>
> I don't think upgrading is the solution; I have tg 1.0.1, and kid
> 0.9.4 which is already 1 step newer than the one on the TG site
> (though apparently 1 older than the current version).

Can you check whether this goes away with Kid 0.9.5? A couple of bugs
have been fixed again. If not, can you provide a simplified test case so
that I can reproduce it?

-- Chris

Ben Sizer

unread,
Feb 10, 2007, 8:35:41 AM2/10/07
to TurboGears
On Feb 10, 6:47 am, Christoph Zwerschke <c...@online.de> wrote:
> Can you check whether this goes away with Kid 0.9.5? A couple of bugs
> have been fixed again. If not, can you provide a simplified test case so
> that I can reproduce it?

Ok, I installed the new version of Kid (which requires a new version
of Setuptools too, incidentally.) There's a change, but not a fix. The
error now looks like:

File "F:\code\pyprojects\whatever\whatever\templates\login.py", line
25, in initialize


File "F:\code\pyprojects\whatever\whatever\templates\master.py",

line 25, in initialize


TypeError: 'NoneType' object is not callable

Error in code generated from template file 'F:\\code\\pyprojects\
\whatever\\whatever\\templates\\login.kid'


Interestingly, I seem to see a pattern where I change something in
master.kid, the next page I serve up is fine, and then I get the error
on the second page. For example, after the above error, I edited some
whitespace in master.kid to force Kid to regenerate the .pyc file. I
hit refresh, and the login page worked just fine. Then when I hit
submit, it gave the same error on the subsequent page, the one that
login submits to. So perhaps there's some sort of problem with the
master template not being reinitialised properly for the second and
subsequent access.

Not sure I can create a reproducible test case, however. The problem
is intermittent for me, and goes away with a server restart. My
master.kid is quite simple, though it does contain comments, which I
know some people have mentioned problems with in the past.

--
Ben Sizer

Christoph Zwerschke

unread,
Feb 10, 2007, 4:38:16 PM2/10/07
to turbo...@googlegroups.com
Ben Sizer wrote:
> Ok, I installed the new version of Kid (which requires a new version
> of Setuptools too, incidentally.) There's a change, but not a fix. The
> error now looks like:
>
> File "F:\code\pyprojects\whatever\whatever\templates\login.py", line
> 25, in initialize
> File "F:\code\pyprojects\whatever\whatever\templates\master.py",
> line 25, in initialize
> TypeError: 'NoneType' object is not callable
> Error in code generated from template file 'F:\\code\\pyprojects\
> \whatever\\whatever\\templates\\login.kid'
>
> Interestingly, I seem to see a pattern where I change something in
> master.kid, the next page I serve up is fine, and then I get the error
> on the second page. For example, after the above error, I edited some
> whitespace in master.kid to force Kid to regenerate the .pyc file. I
> hit refresh, and the login page worked just fine. Then when I hit
> submit, it gave the same error on the subsequent page, the one that
> login submits to. So perhaps there's some sort of problem with the
> master template not being reinitialised properly for the second and
> subsequent access.
>
> Not sure I can create a reproducible test case, however. The problem
> is intermittent for me, and goes away with a server restart. My
> master.kid is quite simple, though it does contain comments, which I
> know some people have mentioned problems with in the past.

You have changed your login template to extend master, right? I was able
to reproduce this and filed it as http://trac.turbogears.org/ticket/1299
already. We'll have to see whether this needs to be fixed in TurboGears,
Kid or both.

-- Chris

Ben Sizer

unread,
Feb 10, 2007, 4:53:31 PM2/10/07
to TurboGears
On Feb 10, 9:38 pm, Christoph Zwerschke <c...@online.de> wrote:

> Ben Sizer wrote:
>
> > Interestingly, I seem to see a pattern where I change something in
> > master.kid, the next page I serve up is fine, and then I get the error
> > on the second page. For example, after the above error, I edited some
> > whitespace in master.kid to force Kid to regenerate the .pyc file. I
> > hit refresh, and the login page worked just fine. Then when I hit
> > submit, it gave the same error on the subsequent page, the one that
> > login submits to. So perhaps there's some sort of problem with the
> > master template not being reinitialised properly for the second and
> > subsequent access.
>
> You have changed your login template to extend master, right?

Yes, my login page extends master.kid. (Though I think it was auto-
generated that way, by the Identity quickstart script.)

> I was able
> to reproduce this and filed it as http://trac.turbogears.org/ticket/1299
> already.

Thanks for filing the bug. It seems like you managed to find a pretty
good minimal case. Hopefully someone more familiar with the system
will be able to suggest a way to get more information out of that
traceback.

You've posted there that "this cannot bite you in production". Is that
because the templates don't get reloaded in production mode?

--
Ben Sizer

Christoph Zwerschke

unread,
Feb 10, 2007, 5:09:34 PM2/10/07
to turbo...@googlegroups.com
Ben Sizer wrote:
> Yes, my login page extends master.kid. (Though I think it was auto-
> generated that way, by the Identity quickstart script.)

At least in 1.0.1 the login page for an --identity project does not
extend master. That's what irritated me at first.

> You've posted there that "this cannot bite you in production". Is that
> because the templates don't get reloaded in production mode?

Yes, autoreload should be off and you usually don't change layout
templates in a running system. If you deploy a new version, you should
explicitly reload the server.

-- Chris

Christoph Zwerschke

unread,
Feb 11, 2007, 4:36:59 AM2/11/07
to turbo...@googlegroups.com
Christoph Zwerschke wrote:

> Ben Sizer wrote:
>> You've posted there that "this cannot bite you in production". Is that
>> because the templates don't get reloaded in production mode?
>
> Yes, autoreload should be off and you usually don't change layout
> templates in a running system. If you deploy a new version, you should
> explicitly reload the server.

This needs clarification I think. The problem is not the autoreloader
(which comes from CherryPy and cares only for .py files, not for .kid
files) but an auto recompile feature in TurboKid that corresponds to the
config setting "kid.precompiled" and that is disabled by default. If
kid.precompiled=True, then TurboGears does not (re)compile kid templates
on the fly, and this problem cannot appear.

-- Christoph

Christoph Zwerschke

unread,
Feb 11, 2007, 4:02:29 PM2/11/07
to turbo...@googlegroups.com
I have now suggested a TurboKid patch to solve this issue:
http://trac.turbogears.org/ticket/1301

Can you check whether this works for you?

Ben Sizer

unread,
Feb 11, 2007, 5:05:15 PM2/11/07
to TurboGears
On Feb 11, 9:02 pm, Christoph Zwerschke <c...@online.de> wrote:
> I have now suggested a TurboKid patch to solve this issue:http://trac.turbogears.org/ticket/1301
>
> Can you check whether this works for you?

I'm developing on Windows so I don't have diff/patch functionality
close at hand. If you want to email me the edited file off-list
however, I'll gladly give it a try.

--
Ben Sizer

Florent Aide

unread,
Feb 11, 2007, 5:12:21 PM2/11/07
to turbo...@googlegroups.com
On 2/11/07, Ben Sizer <kyl...@gmail.com> wrote:

> I'm developing on Windows so I don't have diff/patch functionality
> close at hand. If you want to email me the edited file off-list
> however, I'll gladly give it a try.

Ben,

if you can I suggest you install cygwin on your windows machine. I
always use it when I am on Windows to have the patch/diff functions
and also svn diff/svn status (because tortoisesvn does not produce a
diff file from the changes)

Cheers,

Florent.

Jorge Vargas

unread,
Feb 12, 2007, 12:59:10 AM2/12/07
to turbo...@googlegroups.com
I used to have http://winmerge.org/ always on my windows box, you may
find it usefull.

about the ticket I'll try to take a look at it during the week.

> Cheers,
>
> Florent.
>
> >
>

Christoph Zwerschke

unread,
Feb 12, 2007, 1:37:12 AM2/12/07
to turbo...@googlegroups.com
Florent Aide wrote:
> if you can I suggest you install cygwin on your windows machine. I
> always use it when I am on Windows to have the patch/diff functions
> and also svn diff/svn status (because tortoisesvn does not produce a
> diff file from the changes)

TortoiseSVN can create diffs with the "Create patch..." menu command.

-- Chris

Johnny Blonde

unread,
Apr 24, 2007, 12:01:26 AM4/24/07
to turbo...@googlegroups.com
bump - is this solved in the meantime? i´m having the same problem
with TG 1.0.1, TurboKid-0.9.9-py2.4.egg, kid-0.9.5-py2.4.egg

Jorge Godoy

unread,
Apr 24, 2007, 12:07:53 AM4/24/07
to turbo...@googlegroups.com
Johnny Blonde <frank.wa...@googlemail.com> writes:

> bump - is this solved in the meantime? i´m having the same problem
> with TG 1.0.1, TurboKid-0.9.9-py2.4.egg, kid-0.9.5-py2.4.egg

This what? They're talking about Tortoise and cygwin...

> ---------- Forwarded message ----------
> From: Christoph Zwerschke <c...@online.de>
> Date: 12 Feb., 08:37
> Subject: initialize / NoneType not callable bug
> To: TurboGears
>
>
> Florent Aide wrote:
>> if you can I suggest you install cygwin on your windows machine. I
>> always use it when I am on Windows to have the patch/diff functions
>> and also svn diff/svn status (because tortoisesvn does not produce a
>> diff file from the changes)
>
> TortoiseSVN can create diffs with the "Create patch..." menu command.
>
> -- Chris

--
Jorge Godoy <jgo...@gmail.com>

Johnny Blonde

unread,
Apr 24, 2007, 12:11:00 AM4/24/07
to TurboGears
oh, i´m very sorry - should have refered to
http://groups.google.com/group/turbogears/browse_thread/thread/019c42daa1d5e561/3285e9af024e0dfe
"NoneType not callable bug"

Jorge Godoy

unread,
Apr 24, 2007, 12:38:46 AM4/24/07
to turbo...@googlegroups.com
Johnny Blonde <frank.wa...@googlemail.com> writes:

I believe the status from the bug reports cited there are true. Are you
having different results?

--
Jorge Godoy <jgo...@gmail.com>

Johnny Blonde

unread,
Apr 24, 2007, 1:10:15 AM4/24/07
to TurboGears
no, exactly the same - restarting the server always makes it go away
until i change the template again...

but i´m really lucky to have found out, that this won´t happen in
production state (as long as i don´t constantly change the templates)
which was what i feared...

Christoph Zwerschke

unread,
Apr 24, 2007, 4:48:47 PM4/24/07
to turbo...@googlegroups.com
Johnny Blonde wrote:
> no, exactly the same - restarting the server always makes it go away
> until i change the template again...
>
> but i惴 really lucky to have found out, that this won愒 happen in
> production state (as long as i don愒 constantly change the templates)

> which was what i feared...

That problem is has been solved, but only in the head revision of
TurboKid. The fix is not in the version 0.9.9 used by you and also not
yet in the last released version 1.0.

Somebody needs to create a 1.0.1 release of TurboKid.

-- Chris

Reply all
Reply to author
Forward
0 new messages