Skip to content

Commit

Permalink
Merge pull request #1682 from RogerHaase/1578-examples
Browse files Browse the repository at this point in the history
readthedocs does not provide access to /docs/examples/*; fixes #1578
  • Loading branch information
RogerHaase authored Apr 12, 2024
2 parents 41267f8 + aee6e5c commit cad0d75
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docs/admin/backup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Selective Backup
================
If you want a backup of MoinMoin and your data, then backup the following:

* your data
* your data, ususlly everything under wiki/
* moin configuration, e.g. wikiconfig.py
* logging configuration, e.g. logging.conf
* moin deployment script, e.g. moin.wsgi
Expand Down
9 changes: 5 additions & 4 deletions docs/admin/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ username (like with german umlauts or accented characters). If moin does not
crash (log a Unicode Error), you have likely found the correct coding.

For users configuring GivenAuth on Apache, an example virtual host configuration
file is included with MoinMoin in `docs/examples/deployment/moin-http-basic-auth.conf`.
is included at `/contrib/deployment/moin-http-basic-auth.conf`


LDAPAuth
--------
Expand Down Expand Up @@ -1517,7 +1518,7 @@ the following::
email_tracebacks = True


Please also check the logging configuration example in `docs/examples/config/logging/email`.
Please also check the logging configuration example in `/contrib/logging/email`.

User E-Mail Address Verification
--------------------------------
Expand Down Expand Up @@ -1570,13 +1571,13 @@ https://docs.python.org/3/library/logging.config.html#configuration-file-format


There are also some logging configurations in the
`docs/examples/config/logging/` directory.
`contrib/logging/` directory.

Logging configuration needs to be done very early, usually it will be done
from your adaptor script, e.g. moin.wsgi::

from moin import log
log.load_config('wiki/config/logging/logfile')
log.load_config('contrib/logging/logfile')

You have to fix that path to use a logging configuration matching your
needs (use an absolute path).
Expand Down
2 changes: 1 addition & 1 deletion docs/admin/password-reset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Note: if we say "reset a password" (to use a commonly used term), we mean to
"invalidate the password hash" (so that no password exists that validates
against that hash). MoinMoin does not keep user passwords in cleartext.

The files we refer to below are located in docs/examples/password-reset/...
The files we refer to below are located in contrib/password-reset/...


Resetting one or few password(s)
Expand Down
3 changes: 2 additions & 1 deletion docs/admin/serve.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ because you can't import the application from MoinMoin.
Continue reading here: https://flask.palletsprojects.com/deploying/

In case you run into trouble with deployment of the moin WSGI application,
you can try a simpler WSGI app first. See `docs/examples/deployment/test.wsgi`.
you can try a simpler WSGI app first. An example file is included at
`/contrib/deployment/test.wsgi`.

As long as you can't make `test.wsgi` work, the problem is not with
moin, but rather with your web server and WSGI app deployment method.
Expand Down
2 changes: 1 addition & 1 deletion src/moin/cli/migration/moin19/import19.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def migr_logging(msg_id, log_msg):
"""
The logging function writes the first messages of each type
with warning level and the rest with debug level only.
See docs/examples/config/logging/logfile_cli for logging configuration example
See contrib/logging/logfile_cli for logging configuration example
"""
migr_stat[msg_id] += 1
if migr_stat[msg_id] < migr_warn_max:
Expand Down
17 changes: 10 additions & 7 deletions docs/examples/deployment/moin.fcgi → src/moin/contrib/deployment/moin.fcgi
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"""

# hint: use None as value if the code already is in sys.path
moin_code = None # '/path/to/code'
moin_code = None # '/path/to/code'

wiki_config = '/path/to/config/wikiconfig.py'
wiki_config = "/path/to/config/wikiconfig.py"

import sys, os

Expand All @@ -23,12 +23,14 @@ if moin_code:
sys.path.insert(0, moin_code)

## this works around a bug in flup's CGI autodetection (as of flup 1.0.1):
#os.environ['FCGI_FORCE_CGI'] = 'Y' # 'Y' for (slow) CGI, 'N' for FCGI
# os.environ['FCGI_FORCE_CGI'] = 'Y' # 'Y' for (slow) CGI, 'N' for FCGI

# Creating the Moin (Flask) WSGI application
from moin.app import create_app

application = create_app(wiki_config)


class FixScriptName(object):
"""This middleware fixes the script_name."""

Expand All @@ -37,7 +39,7 @@ class FixScriptName(object):
self.script_name = script_name

def __call__(self, environ, start_response):
environ['SCRIPT_NAME'] = self.script_name
environ["SCRIPT_NAME"] = self.script_name
return self.app(environ, start_response)


Expand All @@ -55,15 +57,16 @@ fix_apache_win32 = False # <-- adapt here as needed

if fix_apache_win32:
from werkzeug.contrib.fixers import PathInfoFromRequestUriFix

application.wsgi_app = PathInfoFromRequestUriFix(application.wsgi_app)

# there are also some more fixers in werkzeug.contrib.fixers - see there
# if the stuff above is not enough for your setup.

## Choose your server mode (threaded, forking or single-thread)
from flup.server.fcgi import WSGIServer
#from flup.server.fcgi_fork import WSGIServer
#from flup.server.fcgi_single import WSGIServer

WSGIServer(application).run()
# from flup.server.fcgi_fork import WSGIServer
# from flup.server.fcgi_single import WSGIServer

WSGIServer(application).run()
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"""

# hint: use None as value if the code already is in sys.path
moin_code = None # '/path/to/code'
moin_code = None # '/path/to/code'

wiki_config = '/path/to/config/wikiconfig.py'
wiki_config = "/path/to/config/wikiconfig.py"

import sys, os

Expand All @@ -31,8 +31,8 @@ if moin_code:

# application is the Flask application
from moin.app import create_app

application = create_app(wiki_config)

# please note: if you want to do some wsgi app wrapping, do it like shown below:
#application.wsgi_app = somewrapper(application.wsgi_app)

# application.wsgi_app = somewrapper(application.wsgi_app)
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import sys
try:
__file__
except NameError:
__file__ = '?'
__file__ = "?"

html_template = """\
<html>
Expand All @@ -68,31 +68,32 @@ row_template = " <tr><td>%s</td><td>%r</td></tr>"


def application(environ, start_response):
""" The WSGI test application """
"""The WSGI test application"""
# emit status / headers
status = "200 OK"
headers = [('Content-Type', 'text/html'), ]
headers = [("Content-Type", "text/html")]
start_response(status, headers)

# assemble and return content
content = html_template % {
'python_version': sys.version,
'platform': sys.platform,
'abs_path': os.path.abspath('.'),
'filename': __file__,
'python_path': repr(sys.path),
'wsgi_env': '\n'.join([row_template % item for item in environ.items()]),
"python_version": sys.version,
"platform": sys.platform,
"abs_path": os.path.abspath("."),
"filename": __file__,
"python_path": repr(sys.path),
"wsgi_env": "\n".join([row_template % item for item in environ.items()]),
}
return [content.encode()]


if __name__ == '__main__':
if __name__ == "__main__":
# this runs when script is started directly from commandline
try:
# create a simple WSGI server and run the application
from wsgiref import simple_server

print("Running test application - point your browser at http://localhost:8080/ ...")
httpd = simple_server.WSGIServer(('', 8080), simple_server.WSGIRequestHandler)
httpd = simple_server.WSGIServer(("", 8080), simple_server.WSGIRequestHandler)
httpd.set_app(application)
httpd.serve_forever()
except ImportError:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/moin/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Or, modify your server adaptor script (e.g. moin.cgi) to do this::
from moin import log
log.load_config('wiki/config/logging/logfile') # XXX please fix this path!
log.load_config('contrib/logging/logfile') # XXX please fix this path!
You have to fix that path to use a logging configuration matching your
needs (we provide some examples in the path given there, it is relative to
Expand Down

0 comments on commit cad0d75

Please sign in to comment.