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 [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.