Skip to content
This repository

view_default conflict errors #394

Closed
mcdonc opened this Issue · 0 comments

1 participant

Chris McDonough
Chris McDonough
Owner

Martin Aspeli writes:

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, 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?

Chris McDonough mcdonc closed this issue from a commit
Chris McDonough - The ``pyramid.view.view_defaults`` decorator did not work properly …
…when

  more than one view relied on the defaults being different for configuration
  conflict resolution.  See #394.

Closes #394.
4c29ef5
Chris McDonough mcdonc closed this in 4c29ef5
Lynn C. Rees lcrees referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.