moinwiki / moin

MoinMoin Wiki Development (2.0+), unstable, for production please use 1.9.x.
https://moinmo.in/
Other
306 stars 92 forks source link

flask 2.0.0, werkzeug 2.0.0, jinja2 3.0.0 will break moin #1109

Closed RogerHaase closed 1 year ago

RogerHaase commented 3 years ago

All of the above are currently RC versions, failures are likely after release.

no module named flask._compat

werkzeug.serving has no attribute BaseRequestHandler

template not found ...xxx.html

workaround:

pip install --upgrade flask==1.1.2
pip install --upgrade werkzeug==1.0.1
pip install --upgrade jinja2==2.11.3
ThomasWaldmann commented 3 years ago

until moin is compatible and f-2 / w-3 / j2-3 is ripe enough, this could also be just a flask<2.0.0 (...) requirement in setup.py.

the question here is also if it is easily possible to be compatible with the new and old releases of these dependencies.

UlrichB22 commented 2 years ago

The fix for werkzeug is described in issue https://github.com/pallets/werkzeug/issues/2114

RogerHaase commented 2 years ago

There is a bug in flask-theme that must be addressed: https://github.com/liuliqiang/flask-theme/issues/13

uiopaubo commented 1 year ago

Since any Debian packaging of Moin 2 will involve using these later package versions, I can report that there are issues with the way item names are encoded as URLs by the current Moin 2 code.

For example, in the moin/templates/modify_select_contenttype.html file, the url_for invocation uses item_name=fqname, but this produces a URL starting with the following:

http://127.0.0.1:8080/+modify/%5B''%252C%20'name_exact'%252C%20'Home'%5D

It seems that this can be remedied by using the string filter in the template:

item_name=fqname|string

Thus producing the following:

http://127.0.0.1:8080/+modify/Home

Similarly, in the moin/items/__init__.py file, in the Default class's _do_modify_show_templates method, the item_name parameter also needs converting to a string:

item_name=str(self.fqname)

Otherwise, the redirect that occurs to be able to edit a new item also produces the invalid URL.

I hope this is useful information. Not being familiar with Jinja templating or the Moin 2 object model, I don't know whether a more fundamental change might make all of these kinds of fixes redundant.

UlrichB22 commented 1 year ago

With the above changes it is possible to run moin with the following versions:

Tested with Debian 11 (bullseye).

Next steps are

  1. move flask-script to flask.cli
  2. migrate to latest version of flask, werkzeug and jinja2
ReimarBauer commented 1 year ago

I can install moin, but can't create a new wiki

./m log new-wiki

Traceback (most recent call last):
  File "/home/reimar/PycharmProjects/moin-venv-python/bin/moin", line 33, in <module>
    sys.exit(load_entry_point('moin', 'console_scripts', 'moin')())
  File "/home/reimar/PycharmProjects/moin/src/moin/scripts/__init__.py", line 44, in main
    from moin.app import create_app
  File "/home/reimar/PycharmProjects/moin/src/moin/app.py", line 19, in <module>
    from moin.utils import monkeypatch
  File "/home/reimar/PycharmProjects/moin/src/moin/utils/monkeypatch.py", line 24, in <module>
    class BaseRequestHandler(werkzeug.serving.BaseRequestHandler):
AttributeError: module 'werkzeug.serving' has no attribute 'BaseRequestHandler'
m-new-wiki.txt (END)

my installed packages

pip list
Package                    Version                          Editable project location
-------------------------- -------------------------------- -------------------------------------
Babel                      2.11.0
blinker                    1.5
cachelib                   0.9.0
chardet                    5.1.0
click                      8.1.3
docutils                   0.19
emeraldtree                0.10.0
feedgen                    0.9.0
Flask                      2.0.3
Flask-Babel                2.0.0
Flask-Caching              2.0.2
Flask-Script               2.0.5
flask-theme                0.3.5
flatland                   0.9.1
greenlet                   2.0.1
importlib-metadata         6.0.0
itsdangerous               2.1.2
Jinja2                     3.0.3
lxml                       4.9.2
Markdown                   3.4.1
MarkupSafe                 2.1.1
moin                       2.0.0.dev830+g1d06fe84.d20230115 /home/reimar/PycharmProjects/moin/src
passlib                    1.7.4
pdfminer3                  2018.12.3.0
pip                        22.0.4
pycryptodome               3.16.0
Pygments                   2.14.0
python-dateutil            2.8.2
pytz                       2022.7.1
setuptools                 58.1.0
six                        1.16.0
sortedcontainers           2.4.0
SQLAlchemy                 1.4.46
Werkzeug                   2.1.2
Whoosh                     2.7.4
XStatic                    1.0.2
XStatic-AnyWikiDraw        0.14.2
XStatic-autosize           1.17.2.1
XStatic-Bootstrap          3.1.1.2
XStatic-CKEditor           3.6.4.0
XStatic-Font-Awesome       6.2.1.0
XStatic-jQuery             3.5.1.1
XStatic-jQuery-File-Upload 4.4.2
XStatic-JQuery.TableSorter 2.14.5.2
XStatic-Pygments           2.9.0.1
XStatic-svg-edit-moin      2012.11.27.1
XStatic-TWikiDraw-moin     2004.10.23.2
zipp                       3.11.0

temporary fixed by WSGIRequestHandler_patch.txt

gets me to

Traceback (most recent call last):
  File "/home/reimar/PycharmProjects/moin-venv-python/bin/moin", line 33, in <module>
    sys.exit(load_entry_point('moin', 'console_scripts', 'moin')())
  File "/home/reimar/PycharmProjects/moin-venv-python/bin/moin", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/home/reimar/miniconda3/lib/python3.9/importlib/metadata.py", line 86, in load
    module = import_module(match.group('module'))
  File "/home/reimar/miniconda3/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/reimar/PycharmProjects/moin/src/moin/scripts/__init__.py", line 11, in <module>
    from flask_script import Manager, Server, Command
  File "/home/reimar/PycharmProjects/moin-venv-python/lib/python3.9/site-packages/flask_script/__init__.py", line 15, in <module>
    from flask._compat import text_type
ModuleNotFoundError: No module named 'flask._compat'

flask-script is deprecated and not compatible

https://github.com/smurfix/flask-script#deprecated

ReimarBauer commented 1 year ago

I was not aware that I can't create with the already done changes a wiki to look at my changes of font-awesome package

seems we have to do something similiar https://medium.datadriveninvestor.com/migrating-flask-script-to-flask-2-0-cli-4a5eee269139

https://blog.miguelgrinberg.com/post/migrating-from-flask-script-to-the-new-flask-cli

UlrichB22 commented 1 year ago

This has been fixed some month ago, please see https://github.com/moinwiki/moin/blob/3ecf14175d90fa3e96cf262060bdb8cc0f6fb5e1/src/moin/utils/monkeypatch.py#L24

Maybe your venv was not updated properly.

I'm working on migrating to Flask cli, but it seems like a lot of work.

RogerHaase commented 1 year ago

See #1331 https://github.com/moinwiki/moin/issues/1331 re. font-awesome 6.2.1.0.

I will work on changing all fa classes to fa-solid. Looks like ~20 files.

On Sun, Jan 15, 2023 at 7:39 AM UlrichB22 @.***> wrote:

This has been fixed some month ago, please see https://github.com/moinwiki/moin/blob/3ecf14175d90fa3e96cf262060bdb8cc0f6fb5e1/src/moin/utils/monkeypatch.py#L24

Maybe your venv was not updated properly.

I'm working on migrating to Flask cli, but it seems like a lot of work.

— Reply to this email directly, view it on GitHub https://github.com/moinwiki/moin/issues/1109#issuecomment-1383167574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGODHVFIF5ZCUZU7CLZI5DWSQD3DANCNFSM43ER6KZQ . You are receiving this because you authored the thread.Message ID: @.***>

RogerHaase commented 1 year ago

Oops, now I see Reimar is already working on this. Will defer.

On Sun, Jan 15, 2023 at 8:04 AM Roger Haase @.***> wrote:

See #1331 https://github.com/moinwiki/moin/issues/1331 re. font-awesome 6.2.1.0.

I will work on changing all fa classes to fa-solid. Looks like ~20 files.

On Sun, Jan 15, 2023 at 7:39 AM UlrichB22 @.***> wrote:

This has been fixed some month ago, please see https://github.com/moinwiki/moin/blob/3ecf14175d90fa3e96cf262060bdb8cc0f6fb5e1/src/moin/utils/monkeypatch.py#L24

Maybe your venv was not updated properly.

I'm working on migrating to Flask cli, but it seems like a lot of work.

— Reply to this email directly, view it on GitHub https://github.com/moinwiki/moin/issues/1109#issuecomment-1383167574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGODHVFIF5ZCUZU7CLZI5DWSQD3DANCNFSM43ER6KZQ . You are receiving this because you authored the thread.Message ID: @.***>

UlrichB22 commented 1 year ago

@ReimarBauer can you please confirm that the errors you reported regarding werkzeug.serving.BaseRequestHandler and flask._compat are fixed in a new Moin installation with the latest github code?

ReimarBauer commented 1 year ago

@UlrichB22 oh my, I have not updated my fork. I confirm that I can create a wiki, thx for that hint.

UlrichB22 commented 1 year ago

Status on this issue

These packages are done:

Following Updates still need more work:

Maybe we can create 2 separate issues for the remaining package updates and close this issue.

RogerHaase commented 1 year ago

agree

UlrichB22 commented 1 year ago

Since any Debian packaging of Moin 2 will involve using these later package versions, I can report that there are issues with the way item names are encoded as URLs by the current Moin 2 code.

For example, in the moin/templates/modify_select_contenttype.html file, the url_for invocation uses item_name=fqname, but this produces a URL starting with the following:

http://127.0.0.1:8080/+modify/%5B''%252C%20'name_exact'%252C%20'Home'%5D

Cannot reproduce this issue, maybe it has been fixed by latest changes.

uiopaubo commented 1 year ago

Since any Debian packaging of Moin 2 will involve using these later package versions, I can report that there are issues with the way item names are encoded as URLs by the current Moin 2 code. For example, in the moin/templates/modify_select_contenttype.html file, the url_for invocation uses item_name=fqname, but this produces a URL starting with the following: http://127.0.0.1:8080/+modify/%5B''%252C%20'name_exact'%252C%20'Home'%5D

Cannot reproduce this issue, maybe it has been fixed by latest changes.

This particular issue goes away when using Flask 2.2 and Jinja 3.1, from testing a Debian unstable installation using the work-in-progress packages, which is very encouraging. Thanks for all the hard work migrating between library versions!