On Thursday, December 19, 2019 at 12:26:34 PM UTC-5, Michael Merickel wrote:
>
> You didn't make it completely clear what you're doing with your 
> view_config but I assume it's something to do with the match_param 
> predicate after your factory updates the matchdict. That's fine, and you 
> could use it to annotate the request with another attribute and then write 
> a custom predicate for your views to use instead of the match_param. Think 
> something like request.user_focus = 'a_username', 
> and @view_config(route_name='user_focus', user_type='a_username') which 
> will work well if they are mutually exclusive.
>

Thanks, Michael.  I'm not doing that, but it looks like i should!

Your reply gave me enough insight/hints to get something working, and I'm 
pretty happy with it from a maintainability standpoint.

I'm now doing the following:



def factory__user_type_discriminator(request):
    """inspects the matchdict's 'integrated_user_identifier' placeholder;
       sets 'user_type=A' or 'user_type=B' in the matchdict
    """
    pass

config.add_route("integrated_user_focus",
                 "/users/{integrated_user_identifier}",
                 factory=factory__user_type_discriminator
                 )


class ViewClass(handler):

    @view_config(route_name="integrated_user_focus", match_param=
'user_type=A')
     def view_type_a(self, request):
        pass
  
    @view_config(route_name="integrated_user_focus", match_param=
'user_type=B')
     def view_type_b(self, request):
        pass







-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/351ad616-1ba0-4f16-b20d-4b8a59590230%40googlegroups.com.

Reply via email to