wagtail-nest / wagtail-personalisation

Rule-based personalisation for Wagtail CMS
http://wagxperience.io/
MIT License
120 stars 34 forks source link

object is not subscriptable #208

Open hazho opened 4 years ago

hazho commented 4 years ago

hi there, request = context['request'] TypeError: 'NoneType' object is not subscriptable

above is the error while visitors browsing the page that uses PersonalisedStructBlock searched everywhere couldn't find the solution..! I assumed it is a bug installed packages and their versions (used freeze): appdirs==1.4.3 asgiref==3.2.5 beautifulsoup4==4.6.0 bumpversion==0.5.3 codecov==2.0.16 command-not-found==0.3 coverage==5.0.3 distlib==0.3.0 Django==3.0.4 django-countries==6.0 django-extensions==2.2.8 django-ipware==2.1.0 django-modelcluster==5.0.1 django-taggit==1.2.0 django-treebeard==4.3.1 djangorestframework==3.11.0 draftjs-exporter==2.1.7 entrypoints==0.3 factory-boy==2.12.0 fail2ban==0.10.2 Faker==4.0.2 filelock==3.0.12 flake8==3.7.9 html5lib==1.0.1 idna==2.6 importlib-metadata==1.5.0 importlib-resources==1.3.1 keyring==10.6.0 keyrings.alt==3.0 l18n==2018.5 mccabe==0.6.1 mock==4.0.2 mypy-extensions==0.4.3 packaging==20.3 Pillow==6.2.2 pluggy==0.13.1 py==1.8.1 pycodestyle==2.5.0 pycrypto==2.6.1 pyflakes==2.1.1 pygobject==3.26.1 pyinotify==0.9.6 pyparsing==2.4.6 python-apt==1.6.5+ubuntu0.2 python-dateutil==2.8.1 pytz==2019.3 pyxdg==0.25 PyYAML==3.12 requests==2.18.4 SecretStorage==2.3.1 six==1.14.0 sqlparse==0.3.1 systemd-python==234 text-unidecode==1.3 toml==0.10.0 tox==3.14.5 typing-extensions==3.7.4.1 ufw==0.36 Unidecode==1.1.1 urllib3==1.22 virtualenv==20.0.10 wagtail==2.8 wagtail-factories==2.0.0 webencodings==0.5.1 Willow==1.3 zipp==3.1.0

it may conflict with one of the packages (but not sure) ...!

hazho commented 4 years ago

now I convert the project to python3.8, but the issue is same

RNCTX commented 3 years ago

Had the same issue, found the fix in a fork....

https://github.com/diurnate/wagtail-personalisation/commit/84da669fdc089ffc67e5fb39dc0ee147d8f63aa8#

easherma-truth commented 2 years ago

Could either of you provide more context for replicating the issue?

RentFreeMedia commented 2 years ago

There are some scenarios that I don't fully understand where request is not in block context. If I remember correctly, the fix was the superclass having request (always) so grabbing it if it doesn't exist in the present block context.

easherma-truth commented 2 years ago

@alxbridge you seem to be the main person maintaining the library at the moment. Would a PR for the changes in https://github.com/diurnate/wagtail-personalisation/commit/84da669fdc089ffc67e5fb39dc0ee147d8f63aa8 be welcome, or is there another way recommended for unit testing blocks that use PersonalizedStructBlock? Happy to help contribute in whatever way makes the most sense.