That's a bug.

On Thu, Jan 5, 2012 at 5:48 PM, Martin Aspeli <optil...@gmail.com> wrote:

> Hi,
>
> I'm toying with some browser detection and basically want the home
> page of my application to be a different view depending on the type of
> user agent.
>
> I have a NewRequest subscriber that adds a marker interface to the
> request depending on whether the browser is desktop or mobile. I then
> have the following view registrations:
>
> @view_defaults(request_type=IMobileRequest)
> class MobileViews(object):
>
>    def __init__(self, request):
>        self.request = request
>
>    @view_config(name='', renderer='templates/mobile_home.pt')
>    def home(self):
>
>        return {
>        }
>
> @view_defaults(request_type=IDesktopRequest)
> class DesktopViews(object):
>
>    def __init__(self, request):
>        self.request = request
>
>    @view_config(name='', renderer='templates/home.pt')
>    def home(self):
>
>        return {
>        }
>
> This results in:
>
>
> pyramid.exceptions.ConfigurationConflictError: Conflicting
> configuration actions
>  For: ('view', None, '', None, <InterfaceClass
> pyramid.interfaces.IView>, None, None, None, None, 'home', False,
> None, None, None, None)
>    Line 23 of file views.py:
>        @view_config(name='', renderer='templates/home.pt')
>    Line 11 of file views.py:
>        @view_config(name='', renderer='templates/mobile_home.pt')
>
> However, if I move the request_type to each view registration, it
> works:
>
> @view_defaults()
> class MobileViews(object):
>
>    def __init__(self, request):
>        self.request = request
>
>    @view_config(name='', request_type=IMobileRequest,
> renderer='templates/mobile_home.pt')
>    def home(self):
>
>        return {
>        }
>
> class DesktopViews(object):
>
>    def __init__(self, request):
>        self.request = request
>
>    @view_config(name='', request_type=IDesktopRequest,
> renderer='templates/home.pt')
>    def home(self):
>
>        return {
>        }
>
> Am I doing something wrong, or is this a bug in Pyramid 1.3a3?
>
> Martin
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to
> pylons-discuss+unsubscr...@googlegroups.com.
> 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 pylons-discuss@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to