pinax-wiki icon indicating copy to clipboard operation
pinax-wiki copied to clipboard

Improperly configured regex in pinax.wiki.urls?

Open jcugley opened this issue 7 years ago • 19 comments

django.core.exceptions.ImproperlyConfigured: "^wiki\(?P<slug>[^/]+)/$" is not a valid regular expression: unbalanced parenthesis at position 20

Not sure why it's getting the error, because I'm not smart enough.

Installed exactly as instructed; Am I doing something wrong?

jcugley avatar Feb 12 '18 22:02 jcugley

@jcugley If you provide a bit more of the stack trace perhaps I can help. Searching all Pinax apps on github I do not find a URLpattern anywhere close to yours.

Are you using the latest pinax-wiki, v1.0.1, published to PyPi on Jan 23, 2018? https://pypi.python.org/pypi/pinax-wiki

For sure "^wiki\(?P<slug>[^/]+)/$" is an invalid pattern. Here's an online analysis: https://regexr.com/3kmca.

grahamu avatar Feb 12 '18 23:02 grahamu

@grahamu I think this is the code in question:

This is the file I think the error is coming from: https://github.com/pinax/pinax-wiki/blob/master/pinax/wiki/urls.py

The code is: url(os.path.join(binder.root, r"(?P<slug>[^/]+)/$"), page, {"binder": binder}, name=binder.page_url_name)

It should be the latest since I only installed it today using pinax start --dev wiki mysite

jcugley avatar Feb 12 '18 23:02 jcugley

@jcugley please show me the "wiki" portion of your urls.py. Perhaps you put in a backslash instead of a forward slash after "^wiki" in that pattern? Double-check against https://github.com/pinax/pinax-wiki/blob/master/README.md#installation urlpattern guidance.

grahamu avatar Feb 13 '18 00:02 grahamu

Oh, now I see you edited your comment to add the use of "pinax" CLI tool. You did not add the urls manually.

Yep, you've discovered a bug... not in pinax-wiki but in pinax-starter-projects, "wiki" branch.

grahamu avatar Feb 13 '18 00:02 grahamu

@jcugley thanks for helping debug this... in your urls.py, try

path("", include("pinax.wiki.urls", namespace="pinax_wiki"))

in place of

path("", include("pinax.wiki.urls"))

This is an oversight in pinax-starter-projects. pinax-wiki urls are namespaced, and namespace="pinax_wiki" should be there.

If you verify proper operation with that change I'll publish the fix to pinax-starter-projects. If this doesn't resolve your issue I'll dig in deeper myself.

grahamu avatar Feb 13 '18 00:02 grahamu

@grahamu still getting the same error when I make that change?

my urlpatterns are:

urlpatterns = [ path("", TemplateView.as_view(template_name="homepage.html"), name="home"), path("admin/", admin.site.urls), path("account/", include("account.urls")), path("", include("pinax.wiki.urls", namespace="pinax_wiki")), ]

jcugley avatar Feb 13 '18 00:02 jcugley

@jcugley Please try one more change if you don't mind. It looks like the path() first argument, an empty string, should be "wiki/".

path("wiki/", include("pinax.wiki.urls", namespace="pinax_wiki")),

If this does not fix your issue, please post the full error stack trace as a gist on https://gist.github.com/. Thanks for helping!

grahamu avatar Feb 13 '18 01:02 grahamu

@grahamu that was one of the things I tried as well, however, I'm still getting this error:

https://gist.github.com/jcugley/a6f991ff65ae5f671fef5554570da1df

jcugley avatar Feb 13 '18 01:02 jcugley

@jcugley What causes the error to appear? Are you trying to see a specific page? Anything to help me isolate the cause would be helpful, thanks.

grahamu avatar Feb 13 '18 01:02 grahamu

@grahamu Can't even run the server, so py manage.py runserver and py manage.py migrate both trigger it.

jcugley avatar Feb 13 '18 01:02 jcugley

Thanks for that feedback @jcugley. I just built a "wikitest" project using pinax-cli as you did. python manage.py migrate worked fine and python manage.py runserver worked fine, albeit with an error when I hit the localhost:8000 page. I found a bunch of errors with templates in the starter project, and an error with pinax-wiki templatetags. It's obvious pinax-wiki and the wiki starter project are not yet up to Django 2.0 standards as these problems are caused by Django deprecations and url namespacing. However, I did not see the same URL issue you reported.

pinax-wiki is not part of the official Pinax 18.01 distribution and pinax-starter-projects doesn't include "wiki" as a supported project, mainly because pinax-wiki has no tests which would catch this sort of problem. That just the nature of immature software, but I apologize for your problems and will do my best to get this working. Thanks for working with me to solve this for you and others.

grahamu avatar Feb 13 '18 02:02 grahamu

@jcugley I've updated and fixed both pinax-wiki and pinax-starter-projects "wiki" branch. Please delete your current mysite project, or at least start again in a new location.

$ pinax start --dev wiki mysite
$ cd mysite
$ pip install -r requirements.txt
$ python manage.py migrate
$ python manage.py runserver

You should see a "Project Wiki" homepage when you browse to localhost:8000.

grahamu avatar Feb 13 '18 02:02 grahamu

@grahamu just did a completely fresh install, now with pinax-wiki-1.0.2 and got exactly the same error... I'm so confused, I'm following all the steps.

jcugley avatar Feb 13 '18 04:02 jcugley

@jcugley are you using virtualenv or pipenv to isolate your development environments?

Perhaps you can join us in Pinax Slack (https://pinax.slack.com) on the #pinax-wiki channel where we can delve into your issues more easily. Ping me there and we'll see what is happening with your setup.

grahamu avatar Feb 13 '18 05:02 grahamu

@grahamu virtualenv with pip, that's not the same as pipenv right?

I think you need to send me a slack invite for that right?

jcugley avatar Feb 13 '18 23:02 jcugley

@jcugley anyone can join Pinax Slack! Hundreds of devs already members. We can talk venv stuff there.

grahamu avatar Feb 13 '18 23:02 grahamu

@grahamu I'm new to slack, how exactly do I join? I'm getting this message when I try to access pinax.slack.com via email login:

"You requested a magic link for logging in to pinax.slack.com. Unfortunately, this email address isn't currently associated with that workspace."

also get this message on the pinax.slack.com page:

"Don't have an account on this workspace yet? Contact the workspace administrator for an invitation"

jcugley avatar Feb 22 '18 00:02 jcugley

@jcugley sorry about my poor earlier directions. Browse to http://slack.pinaxproject.com/ as seen on the bottom of the Pinax project home page. That will get you access to https://pinax.slack.com.

grahamu avatar Feb 22 '18 01:02 grahamu

I have the same problem django.core.exceptions.ImproperlyConfigured: "^wiki\(?P<slug>[^/]+)/$" is not a valid regular expression: unbalanced parenthesis at position 20

django 2.1 python3.6

handbye avatar Jan 26 '19 14:01 handbye