On Thu, Dec 29, 2005 at 09:35:23AM -0500, Kevin Dangoor wrote:
> 
> On 12/29/05, Michele Cella <[EMAIL PROTECTED]> wrote:
> >
> > I've put some time into this, step to reproduce te problem.
> >
> > Let's put this widget into my controllers.py:
> >
> > class MyTextField(widgets.TextField):
> >     template = """
> >     <div xmlns:py="http://purl.org/kid/ns#";>
> >     </div>
> >     """
> > I then modified turbogears/widgets/base.py to:
> >
> >         if isinstance(t, basestring) and "<" in t:
> >             modname = "%s.%s.Template" % (cls.__module__, name)
> >             print modname <- addition
> >             cls.template = kid.load_template(t, name=modname).Template
> >
> > starting the application gives me a loop that prints this:
> >
> > ...
> > turbogears.widgets.base.CalendarDateTimePicker.Template
> > turbogears.widgets.base.AutoCompleteField.Template
> > turbogears.widgets.forms.TableForm.Template
> > turbogears.fastdata.datacontroller.DataGrid.Template
> > playground.controllers.MyTextField.Template
> > 2005/12/29 13:45:08 HTTP INFO SystemExit raised: shutting down
> > autoreloader
> > 2005/12/29 13:45:08 HTTP INFO CherryPy shut down
> > Unhandled exception in thread started by
> > Error in sys.excepthook:
> >
> > The problem is related to widgets that provide a source string as
> > template, in base.py they are loaded with a module name to be then
> > rendered using turbogears kidsupport:
> >
> >         if isinstance(t, basestring) and "<" in t:
> >             modname = "%s.%s.Template" % (cls.__module__, name)
> >             cls.template = kid.load_template(t, name=modname).Template
> >
> > inside kidsupport they are autoreloaded if needed but since they aren't
> > standalone kid files the autoreloader can't find them and raises an
> > exception.
> 
> Hmm... I tried a widget very similar to the one you're trying and I
> couldn't reproduce the problem. Additionally, these templates should
> not be autoreloaded. In the code above, it sets cls.template to the
> Template class itself.
> 
> This is what happens in kidsupport:
> 
>     def transform(self, info, template):
>         if isinstance(template, type):
>             tclass = template
>         else:
>             tclass = self.load_template(template)
> 
> Unless that if statement is wrong (and I didn't think it was), if it's
> passed a template class directly it will just use that, otherwise it
> will run load_template (which is also responsible for the refreshing).
> So, kidsupport shouldn't be doing any reloading of the template
> already.
> 
> Kevin

My thinking was that it had to do with cherrypy autoreloading.  Cherrypy
finds the compiled class in cls.template, but can't find the source class
and throws an exception.

Jason

-- 
If you understand, things are just as they are.  If you do not understand,
things are just as they are.

Attachment: pgpb4VoMSWXnp.pgp
Description: PGP signature

Reply via email to