Pyramid prior to 1.3 had no way to perform subrequests publicly. The reason
is that the renderer attached to a view is only used if that is the active
view for a request. Thus, if you have a URL which is mapped to viewA, and
you want to delegate the request to viewB, the only way to do this is to
call "viewB(request)" and return a Response from viewB (there are obviously
other ways to accomplish this similar idea).

So, the decorator/renderer/etc are only active for the primary view each
request. It is possible in 1.3 using the new introspection api to get the
"active" (or decorated) version of the view and use it.

# find a view that you care about, using the documented properties of a
view introspectable
for v in request.registry.introspector.get_category('views'):
    intr = v['introspectable']
    if intr['route_name'] == 'my_route':
        break
else:
    # no view found
    return HTTPNotFound()
view = v['derived_callable']
 return view(request.context, request)

http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/introspector.html

Anyway, I apologize for this code, it's also not tested, but that is the
basic idea of how you *could* perform a sub-request in pyramid if you
wanted the sub-request to go through security checks, and declarative
renderers.

On Tue, Feb 7, 2012 at 3:30 PM, Jonathan Vanasco <[email protected]>wrote:

> i'm trying to emulate how pylons used subrequests to handle htmlfill
> population on errors ( i'm using pyramid_handlers )
>
> in my pylons emulation code, i have this:
>
> def form_reprint( request, form_print_method , **htmlfill_kwargs ):
>    response= form_print_method()
>
> to call it, i would do:
>    return form_reprint( self.request , self.login_form )
>
> this works as intended if login_form() returns via
> "render_to_response()"
>
> however, if login_form users the @action decorator, login_form returns
> only a dict.
>
> i'm personally not using the @action decorator much, but I'd like to
> get this working nevertheless.
>
> can someone please point me in the right direction?  thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to