City-of-Helsinki / wagtail-svgmap

ImageMap functionality for Wagtail through inline SVGs
BSD 3-Clause "New" or "Revised" License
13 stars 8 forks source link

Updating an SVG file in an ImageMap results in an assertion failure #11

Closed juyrjola closed 8 years ago

juyrjola commented 8 years ago
Environment:

Request Method: POST
Request URL: https://xxx/admin/wagtail_svgmap/imagemap/edit/37/

Django Version: 1.9.10
Python Version: 3.4.3
Installed Applications:
['users',
 'helusers',
 'people',
 'content',
 'kehmet',
 'digi',
 'feedback',
 'search',
 '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',
 'wagtail.contrib.table_block',
 'compressor',
 'modelcluster',
 'taggit',
 'blog',
 'djangobower',
 'wagtail_svgmap',
 'djcelery',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'helusers.providers.helsinki',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.sites',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize']
Installed Middleware:
['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 "/home/digihel/venv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "/home/digihel/venv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/lib/python3.4/contextlib.py" in inner
  30.                 return func(*args, **kwds)

File "/home/digihel/venv/lib/python3.4/site-packages/django/views/decorators/cache.py" in _cache_controlled
  43.             response = viewfunc(request, *args, **kw)

File "/home/digihel/venv/lib/python3.4/site-packages/wagtail/wagtailadmin/decorators.py" in decorated_view
  24.             return view_func(request, *args, **kwargs)

File "/home/digihel/venv/lib/python3.4/site-packages/wagtail/contrib/modeladmin/options.py" in edit_view
  374.         return view_class.as_view(**kwargs)(request)

File "/home/digihel/venv/lib/python3.4/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/home/digihel/venv/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/home/digihel/venv/lib/python3.4/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)

File "/home/digihel/venv/lib/python3.4/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/home/digihel/venv/lib/python3.4/site-packages/wagtail/contrib/modeladmin/views.py" in dispatch
  693.         return super(EditView, self).dispatch(request, *args, **kwargs)

File "/home/digihel/venv/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/home/digihel/venv/lib/python3.4/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)

File "/home/digihel/venv/lib/python3.4/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/home/digihel/venv/lib/python3.4/site-packages/wagtail/contrib/modeladmin/views.py" in dispatch
  75.         return super(WMABaseView, self).dispatch(request, *args, **kwargs)

File "/home/digihel/venv/lib/python3.4/site-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/home/digihel/venv/lib/python3.4/site-packages/django/views/generic/edit.py" in post
  222.             return self.form_valid(form)

File "/home/digihel/venv/lib/python3.4/site-packages/wagtail/contrib/modeladmin/views.py" in form_valid
  163.         instance = form.save()

File "/home/digihel/venv/lib/python3.4/site-packages/modelcluster/forms.py" in save
  224.         instance = super(ClusterForm, self).save(commit=commit)

File "/home/digihel/venv/lib/python3.4/site-packages/django/forms/models.py" in save
  451.             self.instance.save()

File "/home/digihel/venv/src/wagtail-svgmap/wagtail_svgmap/models.py" in save
  87.         if self.recache_ids() | self.recache_svg():  # Using `|` for non-short-circuited or

File "/home/digihel/venv/src/wagtail-svgmap/wagtail_svgmap/models.py" in recache_svg
  117.         new_values = self._render()

File "/home/digihel/venv/src/wagtail-svgmap/wagtail_svgmap/models.py" in _render
  153.             assert link.url in rendered

Exception Type: AssertionError at /admin/wagtail_svgmap/imagemap/edit/37/
Exception Value: 
akx commented 8 years ago

Ah, right.

So for example you're switching from an SVG with IDs X, Y, Z to an SVG with IDs Y, Z, Q; the assertion tries to ensure the link that had been bound to id X is rendered, but naturally it's not, as there's no ID X anymore. Should be an easy fix!