Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1486 (closed enhancement: fixed)

Opened 12 years ago

Last modified 12 years ago

Support Pylons >= 0.9.6 "render" function, not only "render_response".

Reported by: guest Owned by: alberto
Priority: normal Milestone:
Component: ToscaWidgets Version: trunk
Severity: normal Keywords: pylons
Cc: nadako@…

Description

Currently, ToscaWidgets provides a TW-specific render_response function for use in Pylons. However, in Pylons 0.9.6, returning a response object is deprecated and controller actions should return a string now. So it would be cool if TW provided an overriden "render" function as well. In my helper library, I defined a function like this (just a modified TW's render_response variant):

from toscawidgets import framework
from toscawidgets.mods.pylonshf import retrieve_resources
import pylons

def render(*args, **kargs):
    if len(args) > 1 and args[1] in framework.engines:
        engine = args[1]
    else:
        engine = pylons.buffet.default_engine
    framework.default_view = engine
    global_widgets = getattr(pylons.g, 'w', None)
    request_widgets = getattr(pylons.c, 'w', None)
    other_resources = kargs.pop('resources', None)
    pylons.c.resources = retrieve_resources([global_widgets, request_widgets, other_resources])
    return pylons.templating.render(*args, **kargs)

Please, review it and add this function to the pylonshf module! The render function may be useful in Pylons <= 0.9.5 as well. Thanks!

Attachments

pylons_render.patch Download (1.3 KB) - added by guest 12 years ago.
Add "render" function to pylonshf.py file.

Change History

comment:1 Changed 12 years ago by alberto

  • Status changed from new to assigned

Looks good, would you mind posting a patch against trunk's pylonshf.py with it so I can include it?

Thanks, Alberto

Changed 12 years ago by guest

Add "render" function to pylonshf.py file.

comment:2 Changed 12 years ago by guest

Of course. Just added a patch against pylonshf.py. Really, the only changes from the render_response function is its docstring and the return pylons.templating.render(*args, kwargs) call. :-)

comment:3 follow-up: ↓ 4 Changed 12 years ago by guest

Is there any problems with committing this patch? Should I add something to it?

comment:4 in reply to: ↑ 3 Changed 12 years ago by alberto

Replying to guest:

Is there any problems with committing this patch? Should I add something to it?

No, it's fine. Give me a couple of days until I merge the new_host_framework branch back into trunk and I'll apply it.

Alberto

comment:5 Changed 12 years ago by khorn

Status?

Has this change been applied? Will it be?

comment:6 Changed 12 years ago by alberto

  • Status changed from assigned to closed
  • Resolution set to fixed

Yeah, render() is already available in pylonshf.

Alberto

Note: See TracTickets for help on using tickets.