wagtail-nest/wagtail-personalisation

Viewing non-personalised page types fails

gasman opened this issue · 1 comments

From a fresh sandbox instance:

  • Create a new page model (and corresponding template) that doesn't inherit from PersonalisablePageMixin, e.g.

      class StandardPage(Page):
          pass
    
  • Create and publish a page of that type

  • Create a segment which will match the current user (e.g. time between 00:01 and 23:59)

  • Attempt to view the live page

Results in the following 500 error:

Environment:


Request Method: GET
Request URL: http://localhost:8000/sp/

Django Version: 1.11.1
Python Version: 3.6.1
Installed Applications:
['wagtail.wagtailforms',
 'wagtail.wagtailredirects',
 'wagtail.wagtailembeds',
 'wagtail.wagtailsites',
 'wagtail.wagtailusers',
 'wagtail.wagtailsnippets',
 'wagtail.wagtaildocs',
 'wagtail.wagtailimages',
 'wagtail.wagtailsearch',
 'wagtail.wagtailadmin',
 'wagtail.wagtailcore',
 'wagtail.contrib.modeladmin',
 'modelcluster',
 'taggit',
 'debug_toolbar',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'wagtail_personalisation',
 'sandbox.apps.home',
 'sandbox.apps.search',
 'sandbox.apps.user']
Installed Middleware:
['debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'wagtail.wagtailcore.middleware.SiteMiddleware',
 'wagtail.wagtailredirects.middleware.RedirectMiddleware']



Traceback:

File "/Users/matthew/.virtualenvs/wp2/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/Users/matthew/.virtualenvs/wp2/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/Users/matthew/.virtualenvs/wp2/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/Users/matthew/.virtualenvs/wp2/lib/python3.6/site-packages/wagtail/wagtailcore/views.py" in serve
  23.         result = fn(page, request, args, kwargs)

File "/Users/matthew/Development/tbx/wagtail/personalisation/wp2/src/wagtail_personalisation/wagtail_hooks.py" in serve_variation
  80.         variations = _check_for_variations(user_segments, page)

File "/Users/matthew/Development/tbx/wagtail/personalisation/wp2/src/wagtail_personalisation/wagtail_hooks.py" in _check_for_variations
  103.     return page.variants_for_segments(segments)

Exception Type: AttributeError at /sp/
Exception Value: 'StandardPage' object has no attribute 'variants_for_segments'

Should be fixed in master