In TurboGears2 the controller method decorators are not function
decorators, they do not change the function behaviour in any way, they
instead register various hooks and functions that need to be executed
during the request flow.

This means that when you call them you just call a plain function, you are
still exposing the template from add_finish.

If you want to call add_vmware and render its template you should call
override_template (
http://turbogears.readthedocs.org/en/latest/reference/classes.html#tg.decorators.override_template
) right before doing "return self.add_vmware" that way you will switch to
the right template and then return the data from add_vmware for the
template.

On Mon, Feb 9, 2015 at 3:39 AM, <[email protected]> wrote:

> Hello all,
>
> I am a relatively new user of TG2, and came into the project because
> changes in our campus environment finally created a problem that could not
> be fixed in a TG1/Python 2.4 based web application.
>
> The problem I've encountered is in a controller that does some silent
> processing of a form, checks some values and then forwards the user to a
> sub-form to continue adding additional information.  This worked well under
> TG1, but in TG2, the framework appears to be unable to find the template
> (template_name is set to None).
>
> The code fragment looks like this with the line that triggers the fault
> highlighted in bold in the "add_finish" function:
>
>   @expose(template="echidna.templates.machine_add")
>   def add(self, **kw):
>     return dict(page='machine_add',
>                 edit_form=forms.AddMachineFields,
>                 navigation=Markup(nav(current='add_machine', login=False)),
>                 action='/machine/add_finish',
>                 params={},
>                 defaults={})
>
>   @expose()
>   @validate(forms.AddMachineFields, error_handler=add)
>   def add_finish(self, number, provider, chartstring):
>     if provider=='IST VMware':
>       flash('Provider "%s" is supported.'%provider)
>       *return self.add_vmware(number, chartstring)*
>     else:
>       flash('Provider "%s" is not currently supported.'%provider)
>       redirect('/machine/add/')
>
>
>   @expose(template="echidna.templates.machine_add")
>   def add_vmware(self, number, chartstring):
>     params=dict(repetitions=dict(hosts=int(number)))
>     return dict(edit_form=forms.AddMachineVMWare,
>                 navigation = Markup(nav(current='add_machine',
> login=False)),
>                 action = '/machine/vmware_finish'
>                 params=params,
>                 defaults={'number':number,
>                           'chartstring':chartstring})
>
>
>
> I have a work-around that changes the add_finish into a confirmation page,
> but before commiting to adding an extra manual step in the process I am
> asking if there is a proper way to call the add_vmware function from the
> add_finish function within the TG2 framework.
>
> The specific problem report for the code above is:
>
> File "/projects/tg2env/lib/python2.6/site-packages/tg/renderers/genshi.py",
> line *196*, in get_dotted_filename
>
> if not filename.endswith(self.template_extension):
>
> AttributeError: 'NoneType' object has no attribute 'endswith'
>
> Thanks for any information or assistance.
>
> Jeff Makaiwi
> UC Berkeley
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/turbogears.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to