Commits

Thomas Waldmann committed 3bf3bc7 Merge

merged Tech Nossomy's doc fixes

Comments (0)

Files changed (364)

 all:
 	python setup.py build
 
+test:
+	py.test --pep8 -rs
+
 dist: clean-devwiki
 	-rm MANIFEST
 	python setup.py sdist
 	wget -U MoinMoin/Makefile -O contrib/interwiki/intermap.txt "http://master19.moinmo.in/InterWikiMap?action=raw"
 	chmod 664 contrib/interwiki/intermap.txt
 
-check-tabs:
-	@python -c 'import tabnanny ; tabnanny.check("MoinMoin")'
-
 pylint:
 	@pylint --disable-msg=W0142,W0511,W0612,W0613,C0103,C0111,C0302,C0321,C0322 --disable-msg-cat=R MoinMoin
 

MoinMoin/__init__.py

 from MoinMoin.util.version import Version
 
 version = Version(2, 0, 0, 'a0')
-

MoinMoin/_template.py

 
 
 from __future__ import absolute_import, division
-

MoinMoin/_tests/__init__.py

         s.close()
     except socket.error as err:
         raise Exception("connecting to {0}:{1:d}, error: {2!s}".format(host, port, err))
-
-

MoinMoin/_tests/_test_template.py

     can add a test by adding another line to this list
     """
     _tests = (
-        # description,  test,            expected
-        ('Line break',  '<<BR>>',        '<br>'),
+        # description, test, expected
+        ('Line break', '<<BR>>', '<br>'),
     )
 
     from MoinMoin._tests import wikiconfig
         module_tested.do_that()
         result = None
         return result
-

MoinMoin/_tests/ldap_testbase.py

 
 except ImportError:
     pass  # obviously pytest not in use
-

MoinMoin/_tests/ldap_testdata.py

 member: cn=Group A,ou=Groups,ou=testing,dc=example,dc=org
 objectClass: groupOfNames
 """
-

MoinMoin/_tests/test_error.py

         assert result == expected
 
 coverage_modules = ['MoinMoin.error']
-

MoinMoin/_tests/test_sourcecode.py

-# Copyright: 2006 by Armin Rigo (originally only testing for tab chars)
-# Copyright: 2007 adapted and extended (calling the PEP8 checker for most stuff) by MoinMoin:ThomasWaldmann.
-# License: MIT licensed
-
-"""
-Verify that the MoinMoin source files conform (mostly) to PEP8 coding style.
-
-Additionally, we check that the files have no crlf (Windows style) line endings.
-"""
-
-
-import re, time
-import pytest
-import pep8
-
-import py
-
-moindir = py.path.local(__file__).pypkgpath()
-
-EXCLUDE = set([
-    moindir/'static', # this is our dist static stuff
-    moindir/'_tests/wiki', # this is our test wiki
-    moindir/'util/md5crypt.py', # 3rd party, do not fix pep8 there
-])
-
-PEP8IGNORE = (
-    "E121 E122 E123 E124 E125 E126 E127 E128 "  # continuation line indentation
-    "E225 "  # missing whitespace around operator
-    "E241 "  # whitespace around comma (we have some "tabular" formatting in the tests)
-    "E261 "  # less than 2 blanks before inline comment
-    "E301 E302 "  # separate toplevel definitions with 2 empty lines, method defs inside class by 1 empty line
-    "E401 "  # imports on separate lines
-    "E501 "  # maximum line length (default 79 chars)
-    "E502 "  # bug in pep8.py: https://github.com/jcrocholl/pep8/issues/75
-    "W391 "  # trailing blank line(s) at EOF. But: We want one of them so that diff does not complain!
-).split()
-
-TRAILING_SPACES = 'nochange' # 'nochange' or 'fix'
-                             # use 'fix' with extreme caution and in a separate changeset!
-FIX_TS_RE = re.compile(r' +$', re.M) # 'fix' mode: everything matching the trailing space re will be removed
-
-try:
-    import xattr
-    if not hasattr(xattr, "xattr"): # there seem to be multiple modules with that name
-        raise ImportError
-    def mark_file_ok(path, mtime):
-        x = xattr.xattr(path)
-        try:
-            x.set('user.moin-pep8-tested-mtime', str(int(mtime)))
-        except IOError:
-            # probably not supported
-            global mark_file_ok
-            mark_file_ok = lambda path, mtime: None
-
-    def should_check_file(path, mtime):
-        x = xattr.xattr(path)
-        try:
-            mt = x.get('user.moin-pep8-tested-mtime')
-            mt = long(mt)
-            return mtime > mt
-        except IOError:
-            # probably not supported
-            global should_check_file
-            should_check_file = lambda path, mtime: True
-        return True
-except ImportError:
-    def mark_file_ok(path, mtime):
-        pass
-    def should_check_file(path, mtime):
-        return True
-
-RECENTLY = time.time() - 7 * 24*60*60 # we only check stuff touched recently.
-#RECENTLY = 0 # check everything!
-
-# After doing a fresh clone, this procedure is recommended:
-# 1. Run the tests once to see if everything is OK (as cloning updates the mtime,
-#    it will test every file).
-# 2. Before starting to make new changes, use "touch" to change all timestamps
-#    to a time before <RECENTLY>.
-# 3. Regularly run the tests, they will run much faster now.
-
-def pep8_error_count(path):
-    # process_options initializes some data structures and MUST be called before each Checker().check_all()
-    pep8.process_options(['pep8', '--ignore=%s' % ','.join(PEP8IGNORE), '--show-source', 'dummy_path'])
-    error_count = pep8.Checker(path).check_all()
-    return error_count
-
-def check_py_file(reldir, path, mtime):
-    if TRAILING_SPACES == 'fix':
-        f = file(path, 'rb')
-        data = f.read()
-        f.close()
-        fixed = FIX_TS_RE.sub('', data)
-
-        # Don't write files if there's no need for that,
-        # as altering timestamps can be annoying with some tools.
-        if fixed == data:
-            return
-
-        f = file(path, 'wb')
-        f.write(fixed)
-        f.close()
-    # Please read and follow PEP8 - rerun this test until it does not fail any more,
-    # any type of error is only reported ONCE (even if there are multiple).
-    error_count = pep8_error_count(path)
-    assert error_count == 0
-    mark_file_ok(path, mtime)
-
-def pytest_generate_tests(metafunc):
-    for pyfile in sorted(moindir.visit('*.py', lambda p: p not in EXCLUDE)):
-        if pyfile not in EXCLUDE:
-            relpath = moindir.bestrelpath(pyfile)
-            metafunc.addcall(id=relpath, funcargs={'path': pyfile})
-
-def test_sourcecode(path):
-    mtime = path.stat().mtime
-    if mtime < RECENTLY:
-        pytest.skip("source change not recent")
-    if not should_check_file(str(path), mtime):
-        pytest.skip("source marked as should not be checked")
-
-    check_py_file(str(moindir.bestrelpath(path)), str(path), mtime)
-
-

MoinMoin/_tests/test_test_environ.py

     def test_config(self):
         assert isinstance(app.cfg, wikiconfig.Config)
         assert app.cfg.content_acl == CONTENT_ACL
-

MoinMoin/_tests/test_user.py

 
 
 coverage_modules = ['MoinMoin.user']
-

MoinMoin/_tests/test_wikiutil.py

 class TestAnchorNames(object):
     def test_anchor_name_encoding(self):
         tests = [
-            # text                    expected output
-            (u'\xf6\xf6ll\xdf\xdf',   'A.2BAPYA9g-ll.2BAN8A3w-'),
-            (u'level 2',              'level_2'),
-            (u'level_2',              'level_2'),
-            (u'',                     'A'),
-            (u'123',                  'A123'),
+            # text, expected output
+            (u'\xf6\xf6ll\xdf\xdf', 'A.2BAPYA9g-ll.2BAN8A3w-'),
+            (u'level 2', 'level_2'),
+            (u'level_2', 'level_2'),
+            (u'', 'A'),
+            (u'123', 'A123'),
             # make sure that a valid anchor is not modified:
             (u'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:_.-',
              u'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:_.-')
 
 def testfile_headers():
     test_headers = [
-                #test_file               #content_type
-                ('imagefile.gif',       'image/gif'),
-                ('testfile.txt',        'text/plain'),
-                ('pdffile.pdf',         'application/pdf'),
-                ('docfile.doc',         'application/msword'),
-                (None,                  'application/octet-stream')
+                #test_file, content_type
+                ('imagefile.gif', 'image/gif'),
+                ('testfile.txt', 'text/plain'),
+                ('pdffile.pdf', 'application/pdf'),
+                ('docfile.doc', 'application/msword'),
+                (None, 'application/octet-stream')
                 ]
 
     for test_file, content_type in test_headers:
     assert result == expected
 
 coverage_modules = ['MoinMoin.wikiutil']
-

MoinMoin/_tests/wiki/data/plugin/__init__.py

 """
 This file was added so as to make hg track the folders necessary for the tests.
 """
-

MoinMoin/_tests/wikiconfig.py

     interwikiname = u'MoinTest'
     interwiki_map = dict(Self='http://localhost:8080/', MoinMoin='http://moinmo.in/')
     interwiki_map[interwikiname] = 'http://localhost:8080/'
-
         # can happen if teardown_wiki() is called twice, e.g. by unit tests.
         pass
     return response
-

MoinMoin/apps/__init__.py

 - admin Module for special stuff for wiki admins
 - serve Module for static file serving
 """
-

MoinMoin/apps/admin/__init__.py

 from flask import Blueprint
 admin = Blueprint('admin', __name__, template_folder='templates')
 import MoinMoin.apps.admin.views
-

MoinMoin/apps/admin/_tests/test_admin.py

 
     def test_itemsize(self):
         self._test_view_get(url_for('admin.itemsize'))
-

MoinMoin/apps/admin/templates/admin/highlighterhelp.html

 <h1>{{ _("Available Highlighters") }}</h1>
 {{ utils.table(headings, rows) }}
 {% endblock %}
-

MoinMoin/apps/admin/templates/admin/index.html

     <li><a href="{{ url_for('admin.highlighterhelp') }}">{{ _("Available Highlighters") }}</a></li>
 </ul>
 {% endblock %}
-

MoinMoin/apps/admin/templates/admin/interwikihelp.html

 <h1>{{ _("Known InterWiki names") }}</h1>
 {{ utils.table(headings, rows) }}
 {% endblock %}
-

MoinMoin/apps/admin/templates/admin/itemsize.html

 <h1>{{ _("Item sizes (latest revision)") }}</h1>
 {{ utils.table(headings, rows) }}
 {% endblock %}
-

MoinMoin/apps/admin/templates/admin/sysitems_upgrade.html

 </fieldset>
 </form>
 {% endblock %}
-

MoinMoin/apps/admin/templates/admin/userbrowser.html

     {% endfor %}
 </table>
 {% endblock %}
-

MoinMoin/apps/admin/templates/admin/wikiconfig.html

 </tdbody>
 </table>
 {% endblock %}
-

MoinMoin/apps/admin/templates/admin/wikiconfighelp.html

     </table>
 {% endfor %}
 {% endblock %}
-

MoinMoin/apps/admin/views.py

                            title_name=_(u"Item Size"),
                            headings=headings,
                            rows=rows)
-
-

MoinMoin/apps/feed/__init__.py

 from flask import Blueprint
 feed = Blueprint('feed', __name__)
 import MoinMoin.apps.feed.views
-

MoinMoin/apps/feed/_tests/test_feed.py

             assert rv.headers['Content-Type'] == 'application/atom+xml'
             assert rv.data.startswith('<?xml')
             assert "checking if the cache invalidation works" in rv.data
-

MoinMoin/apps/feed/views.py

         if cid is not None:
             app.cache.set(cid, content)
     return Response(content, content_type='application/atom+xml')
-

MoinMoin/apps/frontend/__init__.py

 from flask import Blueprint
 frontend = Blueprint('frontend', __name__)
 import MoinMoin.apps.frontend.views
-

MoinMoin/apps/frontend/_tests/test_frontend.py

         if email is None:
             email = "user@example.org"
         user.create_user(name, password, email, is_encrypted=pwencoded)
-

MoinMoin/apps/frontend/views.py

+# Copyright: 2012 MoinMoin:CheerXiao
 # Copyright: 2003-2010 MoinMoin:ThomasWaldmann
 # Copyright: 2011 MoinMoin:AkashSinha
 # Copyright: 2011 MoinMoin:ReimarBauer
 from datetime import datetime
 from itertools import chain
 from collections import namedtuple
+from functools import wraps
+
 try:
     import json
 except ImportError:
     return html
 
 
+def presenter(view, add_trail=False, abort404=True):
+    """
+    Decorator to create new "presenter" views.
+
+    Presenter views handle GET requests to locations like
+    +{view}/+<rev>/<item_name> and +{view}/<item_name>, and always try to
+    look up the item before processing.
+
+    :param view: name of view
+    :param add_trail: whether to call flaskg.user.add_trail
+    :param abort404: whether to abort(404) for nonexistent items
+    """
+    def decorator(wrapped):
+        @frontend.route('/+{view}/+<rev>/<itemname:item_name>'.format(view=view))
+        @frontend.route('/+{view}/<itemname:item_name>'.format(view=view), defaults=dict(rev=CURRENT))
+        @wraps(wrapped)
+        def wrapper(item_name, rev):
+            if add_trail:
+                flaskg.user.add_trail(item_name)
+            try:
+                item = Item.create(item_name, rev_id=rev)
+            except AccessDenied:
+                abort(403)
+            if abort404 and isinstance(item, NonExistent):
+                abort(404, item_name)
+            return wrapped(item)
+        return wrapper
+    return decorator
+
+
 @frontend.route('/<itemname:item_name>', defaults=dict(rev=CURRENT), methods=['GET'])
 @frontend.route('/+show/+<rev>/<itemname:item_name>', methods=['GET'])
 def show_item(item_name, rev):
     return redirect(url_for_item(item_name))
 
 
-@frontend.route('/+dom/+<rev>/<itemname:item_name>')
-@frontend.route('/+dom/<itemname:item_name>', defaults=dict(rev=CURRENT))
-def show_dom(item_name, rev):
-    try:
-        item = Item.create(item_name, rev_id=rev)
-    except AccessDenied:
-        abort(403)
+@presenter('dom', abort404=False)
+def show_dom(item):
     if isinstance(item, NonExistent):
         status = 404
     else:
     return Response(content, 200, mimetype='text/plain')
 
 
-@frontend.route('/+highlight/+<rev>/<itemname:item_name>')
-@frontend.route('/+highlight/<itemname:item_name>', defaults=dict(rev=CURRENT))
-def highlight_item(item_name, rev):
-    try:
-        item = Item.create(item_name, rev_id=rev)
-    except AccessDenied:
-        abort(403)
-    if isinstance(item, NonExistent):
-        abort(404, item_name)
+@presenter('highlight')
+def highlight_item(item):
     return render_template('highlight.html',
                            item=item, item_name=item.name,
                            data_text=Markup(item._render_data_highlight()),
                           )
 
 
-@frontend.route('/+meta/<itemname:item_name>', defaults=dict(rev=CURRENT))
-@frontend.route('/+meta/+<rev>/<itemname:item_name>')
-def show_item_meta(item_name, rev):
-    flaskg.user.add_trail(item_name)
-    try:
-        item = Item.create(item_name, rev_id=rev)
-    except AccessDenied:
-        abort(403)
-    if isinstance(item, NonExistent):
-        abort(404, item_name)
-    show_revision = rev != CURRENT
+@presenter('meta', add_trail=True)
+def show_item_meta(item):
+    show_revision = request.view_args['rev'] != CURRENT
     show_navigation = False # TODO
     first_rev = None
     last_rev = None
                            data_rendered=Markup(item._render_data()),
                            )
 
-@frontend.route('/+get/+<rev>/<itemname:item_name>')
-@frontend.route('/+get/<itemname:item_name>', defaults=dict(rev=CURRENT))
-def get_item(item_name, rev):
-    try:
-        item = Item.create(item_name, rev_id=rev)
-    except AccessDenied:
-        abort(403)
+@presenter('get')
+def get_item(item):
     return item.do_get()
 
-@frontend.route('/+download/+<rev>/<itemname:item_name>')
-@frontend.route('/+download/<itemname:item_name>', defaults=dict(rev=CURRENT))
-def download_item(item_name, rev):
-    try:
-        item = Item.create(item_name, rev_id=rev)
-        mimetype = request.values.get("mimetype")
-    except AccessDenied:
-        abort(403)
+@presenter('download')
+def download_item(item):
+    mimetype = request.values.get("mimetype")
     return item.do_get(force_attachment=True, mimetype=mimetype)
 
 @frontend.route('/+convert/<itemname:item_name>')
 def page_not_found(e):
     return render_template('404.html',
                            item_name=e.description), 404
-

MoinMoin/apps/misc/__init__.py

 from flask import Blueprint
 misc = Blueprint('misc', __name__, template_folder='templates')
 import MoinMoin.apps.misc.views
-

MoinMoin/apps/misc/_tests/test_misc.py

             rv = c.get(url_for('misc.urls_names'))
             assert rv.status == '200 OK'
             assert rv.headers['Content-Type'] == 'text/plain; charset=utf-8'
-

MoinMoin/apps/misc/views.py

     item_names = sorted([rev.meta[NAME] for rev in flaskg.storage.documents(wikiname=app.cfg.interwikiname)])
     content = render_template('misc/urls_names.txt', item_names=item_names)
     return Response(content, mimetype='text/plain')
-

MoinMoin/apps/serve/__init__.py

 from flask import Blueprint
 serve = Blueprint('serve', __name__)
 import MoinMoin.apps.serve.views
-

MoinMoin/apps/serve/_tests/test_serve.py

             assert rv.status == '404 NOT FOUND'
             assert rv.headers['Content-Type'] == 'text/html'
             assert '<!DOCTYPE HTML' in rv.data
-

MoinMoin/apps/serve/views.py

         abort(404)
 
     return send_from_directory(base_path, filename)
-

MoinMoin/auth/__init__.py

                 userobj = None
     logging.debug("session started for user {0!r}".format(userobj))
     return userobj
-

MoinMoin/auth/_tests/test_auth.py

     assert 'password=test_pass' in test_url
     assert 'stage=test_auth_name' in test_url
     assert 'login_submit=1' in test_url
-

MoinMoin/auth/_tests/test_http.py

         test_user, bool_val = httpauthmoin_obj.request(flaskg.user)
         assert not test_user.valid
         assert test_user.name == u'anonymous'
-

MoinMoin/auth/_tests/test_ldap_login.py

         u2 = handle_login(None, username='usera', password='usera')
         assert u2 is not None
         assert u2.valid
-

MoinMoin/auth/_tests/test_log.py

         assert test_user.name == u'anonymous'
         assert not test_user.valid
         assert bool_value
-

MoinMoin/auth/http.py

         else:
             logging.debug("returning {0!r}".format(user_obj))
             return user_obj, True
-

MoinMoin/auth/ldap_login.py

         except:
             logging.exception("caught an exception, traceback follows...")
             return ContinueLogin(user_obj)
-

MoinMoin/auth/log.py

     def logout(self, user_obj, **kw):
         self.log('logout', user_obj, kw)
         return user_obj, True
-

MoinMoin/auth/openidrp.py

 
                 # returns a MultistageFormLogin
                 return MultistageFormLogin(form_html)
-

MoinMoin/auth/smb_mount.py

         if user_obj and not user_obj.valid:
             self.do_smb(user_obj.name, None, False)
         return user_obj, True
-

MoinMoin/config/__init__.py

 from MoinMoin.constants.contenttypes import *
 from MoinMoin.constants.keys import *
 from MoinMoin.constants.misc import *
-

MoinMoin/config/_tests/test_defaultconfig.py

                 assert result == (pw_error is None)
 
 coverage_modules = ['MoinMoin.config.default']
-

MoinMoin/config/default.py

 
 _add_options_to_defconfig(options)
 _add_options_to_defconfig(options_no_group_name, False)
-

MoinMoin/conftest.py

         if coverage is not None:
             coverage_modules.update(getattr(self.obj, 'coverage_modules', []))
         return super(Module, self).run(*args, **kwargs)
-

MoinMoin/constants/__init__.py

 """
 MoinMoin - modules with constant definitions
 """
-

MoinMoin/constants/chartypes.py

 chars_digits = u"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039\u00b2\u00b3\u00b9\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\u06f0\u06f1\u06f2\u06f3\u06f4\u06f5\u06f6\u06f7\u06f8\u06f9\u0966\u0967\u0968\u0969\u096a\u096b\u096c\u096d\u096e\u096f\u09e6\u09e7\u09e8\u09e9\u09ea\u09eb\u09ec\u09ed\u09ee\u09ef\u0a66\u0a67\u0a68\u0a69\u0a6a\u0a6b\u0a6c\u0a6d\u0a6e\u0a6f\u0ae6\u0ae7\u0ae8\u0ae9\u0aea\u0aeb\u0aec\u0aed\u0aee\u0aef\u0b66\u0b67\u0b68\u0b69\u0b6a\u0b6b\u0b6c\u0b6d\u0b6e\u0b6f\u0be7\u0be8\u0be9\u0bea\u0beb\u0bec\u0bed\u0bee\u0bef\u0c66\u0c67\u0c68\u0c69\u0c6a\u0c6b\u0c6c\u0c6d\u0c6e\u0c6f\u0ce6\u0ce7\u0ce8\u0ce9\u0cea\u0ceb\u0cec\u0ced\u0cee\u0cef\u0d66\u0d67\u0d68\u0d69\u0d6a\u0d6b\u0d6c\u0d6d\u0d6e\u0d6f\u0e50\u0e51\u0e52\u0e53\u0e54\u0e55\u0e56\u0e57\u0e58\u0e59\u0ed0\u0ed1\u0ed2\u0ed3\u0ed4\u0ed5\u0ed6\u0ed7\u0ed8\u0ed9\u0f20\u0f21\u0f22\u0f23\u0f24\u0f25\u0f26\u0f27\u0f28\u0f29\u1040\u1041\u1042\u1043\u1044\u1045\u1046\u1047\u1048\u1049\u1369\u136a\u136b\u136c\u136d\u136e\u136f\u1370\u1371\u17e0\u17e1\u17e2\u17e3\u17e4\u17e5\u17e6\u17e7\u17e8\u17e9\u1810\u1811\u1812\u1813\u1814\u1815\u1816\u1817\u1818\u1819\u2070\u2074\u2075\u2076\u2077\u2078\u2079\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089\u2460\u2461\u2462\u2463\u2464\u2465\u2466\u2467\u2468\u2474\u2475\u2476\u2477\u2478\u2479\u247a\u247b\u247c\u2488\u2489\u248a\u248b\u248c\u248d\u248e\u248f\u2490\u24ea\u24f5\u24f6\u24f7\u24f8\u24f9\u24fa\u24fb\u24fc\u24fd\u2776\u2777\u2778\u2779\u277a\u277b\u277c\u277d\u277e\u2780\u2781\u2782\u2783\u2784\u2785\u2786\u2787\u2788\u278a\u278b\u278c\u278d\u278e\u278f\u2790\u2791\u2792\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19"
 
 chars_spaces = u"\u0009\u000a\u000b\u000c\u000d\u001c\u001d\u001e\u001f\u0020\u0085\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000"
-
-
-

MoinMoin/constants/contenttypes.py

         ('application/octet-stream', 'binary file'),
     ]),
 ]
-

MoinMoin/constants/keys.py

 # index names
 LATEST_REVS = 'latest_revs'
 ALL_REVS = 'all_revs'
-

MoinMoin/constants/misc.py

                'notes',
                'rtp', 'rtsp', 'rtcp',
               ]
-

MoinMoin/constants/rights.py

 
 # rights that control access to operations on contents
 ACL_RIGHTS_CONTENTS = [READ, WRITE, CREATE, ADMIN, DESTROY, ]
-

MoinMoin/constants/tools/chartypes_create.py

 
 if __name__ == '__main__':
     main()
-

MoinMoin/converter/__init__.py

 
 default_registry = RegistryConverter()
 load_package_modules(__name__, __path__)
-

MoinMoin/converter/_args.py

             yield value
         for value in self.keyword.itervalues():
             yield value
-

MoinMoin/converter/_args_wiki.py

         ret.append(key + u'=' + value)
 
     return u' '.join(ret)
-

MoinMoin/converter/_table.py

             table_body.append(table_row)
         table.append(table_body)
         return table
-

MoinMoin/converter/_tests/test__args.py

     assert l[1] == 'both'
     assert True in l
     assert False in l
-

MoinMoin/converter/_tests/test__args_wiki.py

 
     s = unparse(Arguments(positional, keyword))
     assert s == wiki
-

MoinMoin/converter/_tests/test__wiki_macro.py

         result = self.conv.parser(name, args, text)
         if output is not None or result is not None:
             assert self.serialize(result) == output
-

MoinMoin/converter/_tests/test_creole_in.py

     def do(self, input, output, args={}):
         out = self.conv(input, 'text/x.moin.creole;charset=utf-8', **args)
         assert self.serialize(out) == output
-

MoinMoin/converter/_tests/test_docbook_in.py

         ]
         for i in data:
             yield (self.do_nonamespace, ) + i
-

MoinMoin/converter/_tests/test_docbook_out.py

         ]
         for i in data:
             yield (self.do, ) + i
-

MoinMoin/converter/_tests/test_html_in.py

         ]
         for i in data:
             yield (self.do, ) + i
-

MoinMoin/converter/_tests/test_html_in_out.py

         ]
         for i in data:
             yield (self.do, ) + i
-

MoinMoin/converter/_tests/test_html_out.py

     def test_unknown(self):
         page = ET.XML("<page:unknown {0}/>".format(self.input_namespaces))
         pytest.raises(ElementException, self.conv.__call__, page)
-

MoinMoin/converter/_tests/test_include.py

         rendered = MoinWiki.create(u'page1')._render_data()
         assert '<p />' not in rendered
         assert '<p></p>' not in rendered
-

MoinMoin/converter/_tests/test_link.py

         assert sorted(links_result) == sorted(links_expected)
         assert sorted(transclusions_result) == sorted(transclusions_expected)
         assert sorted(external_result) == sorted(external_expected)
-

MoinMoin/converter/_tests/test_mediawiki_in.py

         assert self.serialize(out) == output
 
 coverage_modules = ['MoinMoin.converter.mediawiki_in']
-

MoinMoin/converter/_tests/test_moinwiki19_in.py

         ]
         for i in data:
             yield (self.do, ) + i
-

MoinMoin/converter/_tests/test_moinwiki_in.py

             pytest.skip(skip)
         out = self.conv(input, 'text/x.moin.wiki;charset=utf-8', **args)
         assert self.serialize(out) == output
-

MoinMoin/converter/_tests/test_moinwiki_in_out.py

         out = self.conv_in(input, 'text/x.moin.wiki;charset=utf-8', **args)
         out = self.conv_out(self.handle_input(self.serialize(out)), **args)
         assert self.handle_output(out) == output
-

MoinMoin/converter/_tests/test_moinwiki_out.py

             yield (self.do, ) + i
 
 coverage_modules = ['MoinMoin.converter.moinwiki_out']
-

MoinMoin/converter/_tests/test_rst_in.py

         assert self.serialize(out) == output
 
 coverage_modules = ['MoinMoin.converter.rst_in']
-

MoinMoin/converter/_tests/test_rst_out.py

             yield (self.do, ) + i
 
 coverage_modules = ['MoinMoin.converter.rst_out']
-

MoinMoin/converter/_tests/test_smiley.py

     result = tree.xpath(query)
     print 'query result:', result
     assert result
-

MoinMoin/converter/_util.py

     text = text.replace(u'\r\n', u'\n')
     lines = text.split(u'\n')
     return lines
-

MoinMoin/converter/_wiki_macro.py

             elem.append(moin_page.body(children=content))
 
         return elem
-

MoinMoin/converter/archive_in.py

 default_registry.register(TarConverter._factory, Type('application/x-tar'), type_moin_document)
 default_registry.register(TarConverter._factory, Type('application/x-gtar'), type_moin_document)
 default_registry.register(ZipConverter._factory, Type('application/zip'), type_moin_document)
-

MoinMoin/converter/audio_video_in.py

 default_registry.register(Converter._factory, Type('video/webm'), type_moin_document)
 default_registry.register(Converter._factory, Type('audio/ogg'), type_moin_document)
 default_registry.register(Converter._factory, Type('audio/wave'), type_moin_document)
-

MoinMoin/converter/creole_in.py

 from MoinMoin.util.mime import Type, type_moin_document, type_moin_creole
 default_registry.register(Converter.factory, type_moin_creole, type_moin_document)
 default_registry.register(Converter.factory, Type('x-moin/format;name=creole'), type_moin_document)
-

MoinMoin/converter/docbook_in.py

 from . import default_registry
 from MoinMoin.util.mime import Type, type_moin_document
 default_registry.register(Converter._factory, Type('application/docbook+xml'), type_moin_document)
-

MoinMoin/converter/docbook_out.py

 from MoinMoin.util.mime import Type, type_moin_document
 default_registry.register(Converter._factory, type_moin_document,
     Type('application/docbook+xml'))
-

MoinMoin/converter/everything.py

                           default_registry.PRIORITY_MIDDLE + 3)
 default_registry.register(Converter._factory, Type(type=None, subtype=None), type_moin_document,
                           default_registry.PRIORITY_MIDDLE + 3)
-

MoinMoin/converter/highlight.py

 from . import default_registry
 from MoinMoin.util.mime import Type, type_moin_document
 default_registry.register(Converter._factory, type_moin_document, type_moin_document)
-

MoinMoin/converter/html_in.py

 from . import default_registry
 from MoinMoin.util.mime import Type, type_moin_document
 default_registry.register(Converter._factory, Type('text/html'), type_moin_document)
-

MoinMoin/converter/html_out.py

 from . import default_registry
 from MoinMoin.util.mime import Type, type_moin_document
 default_registry.register(ConverterPage._factory, type_moin_document, Type('application/x-xhtml-moin-page'))
-

MoinMoin/converter/image_in.py

 default_registry.register(Converter._factory, Type('image/png'), type_moin_document)
 default_registry.register(Converter._factory, Type('image/jpeg'), type_moin_document)
 default_registry.register(Converter._factory, Type('image/gif'), type_moin_document)
-

MoinMoin/converter/include.py

 from . import default_registry
 from MoinMoin.util.mime import Type, type_moin_document
 default_registry.register(Converter._factory, type_moin_document, type_moin_document)
-

MoinMoin/converter/link.py

 from . import default_registry
 default_registry.register(ConverterExternOutput._factory, type_moin_document, type_moin_document)
 default_registry.register(ConverterItemRefs._factory, type_moin_document, type_moin_document)
-

MoinMoin/converter/macro.py

 from . import default_registry
 from MoinMoin.util.mime import Type, type_moin_document
 default_registry.register(Converter._factory, type_moin_document, type_moin_document)
-

MoinMoin/converter/mediawiki_in.py

     class Mediawiki_preprocessor(object):
 
         class Preprocessor_tag(object):
-            def __init__(self, name='', text='', tag='',  status=True):
+            def __init__(self, name='', text='', tag='', status=True):
                 self.tag_name = name
                 self.tag = tag
                 self.text = [text]
 from MoinMoin.util.mime import Type, type_moin_document
 default_registry.register(Converter.factory, Type('x-moin/format;name=mediawiki'), type_moin_document)
 default_registry.register(Converter.factory, Type('text/x-mediawiki'), type_moin_document)
-

MoinMoin/converter/moinwiki19_in.py

 from MoinMoin.util.mime import Type, type_moin_document, type_moin_wiki
 default_registry.register(ConverterFormat19.factory, Type('text/x.moin.wiki;format=1.9'), type_moin_document)
 default_registry.register(ConverterFormat19.factory, Type('x-moin/format;name=wiki;format=1.9'), type_moin_document)
-
-

MoinMoin/converter/moinwiki_in.py

 from MoinMoin.util.mime import Type, type_moin_document, type_moin_wiki
 default_registry.register(Converter.factory, type_moin_wiki, type_moin_document)
 default_registry.register(Converter.factory, Type('x-moin/format;name=wiki'), type_moin_document)
-
-

MoinMoin/converter/moinwiki_out.py

 from MoinMoin.util.mime import Type, type_moin_document, type_moin_wiki
 default_registry.register(Converter.factory, type_moin_document, type_moin_wiki)
 default_registry.register(Converter.factory, type_moin_document, Type('x-moin/format;name=wiki'))
-

MoinMoin/converter/nonexistent_in.py

 from . import default_registry
 from MoinMoin.util.mime import Type, type_moin_document
 default_registry.register(Converter._factory, Type('application/x-nonexistent'), type_moin_document)
-

MoinMoin/converter/opendocument_in.py

 
 for t in openoffice_types:
     default_registry.register(OpenOfficeIndexingConverter._factory, Type(t), type_text_plain)
-

MoinMoin/converter/pdf_in.py

 from . import default_registry
 from MoinMoin.util.mime import Type, type_text_plain
 default_registry.register(PDFIndexingConverter._factory, Type('application/pdf'), type_text_plain)
-

MoinMoin/converter/pygments_in.py

                 blockcode.append(line.expandtabs())
             body = moin_page.body(children=(blockcode, ))
             return moin_page.page(children=(body, ))
-

MoinMoin/converter/rst_in.py

                           Type('text/x-rst'), type_moin_document)
 default_registry.register(Converter.factory,
                           Type('x-moin/format;name=rst'), type_moin_document)
-

MoinMoin/converter/rst_out.py

 default_registry.register(Converter.factory,
                           type_moin_document,
                           Type('x-moin/format;name=rst'))
-

MoinMoin/converter/smiley.py

 from . import default_registry
 from MoinMoin.util.mime import type_moin_document
 default_registry.register(Converter._factory, type_moin_document, type_moin_document)
-

MoinMoin/converter/text_csv_in.py

 from . import default_registry
 from MoinMoin.util.mime import Type, type_moin_document
 default_registry.register(Converter._factory, Type('text/csv'), type_moin_document)
-

MoinMoin/converter/text_in.py

 from MoinMoin.util.mime import Type, type_moin_document
 default_registry.register(Converter._factory, Type(type='text'), type_moin_document,
                           default_registry.PRIORITY_MIDDLE + 2)
-

MoinMoin/converter/text_out.py

 from . import default_registry
 from MoinMoin.util.mime import Type, type_moin_document, type_text_plain
 default_registry.register(Converter.factory, type_moin_document, type_text_plain)
-

MoinMoin/converter/xml_in.py

 from . import default_registry
 from MoinMoin.util.mime import Type, type_text_plain
 default_registry.register(XMLIndexingConverter._factory, Type('text/xml'), type_text_plain)
-

MoinMoin/datastruct/__init__.py

 
 from MoinMoin.datastruct.backends import GroupDoesNotExistError
 from MoinMoin.datastruct.backends import DictDoesNotExistError
-

MoinMoin/datastruct/backends/__init__.py

             return self[key]
         except DictDoesNotExistError:
             return default
-

MoinMoin/datastruct/backends/_tests/__init__.py

                 assert u'SomeNotExistingKey' not in test_dict
                 assert test_dict.get(u'SomeNotExistingKey') is None
                 assert test_dict.get(u'SomeNotExistingKey', {}) == {}
-

MoinMoin/datastruct/backends/_tests/test_composite_dicts.py

 
 
 coverage_modules = ['MoinMoin.datastruct.backends.composite_dicts']
-

MoinMoin/datastruct/backends/_tests/test_composite_groups.py

 
 
 coverage_modules = ['MoinMoin.datastruct.backends.composite_groups']
-

MoinMoin/datastruct/backends/_tests/test_config_dicts.py

             assert result in expected
 
 coverage_modules = ['MoinMoin.datastruct.backends.config_dicts']
-

MoinMoin/datastruct/backends/_tests/test_config_groups.py

 
 
 coverage_modules = ['MoinMoin.datastruct.backends.config_groups']
-

MoinMoin/datastruct/backends/_tests/test_lazy_config_groups.py

 
 
 coverage_modules = ['MoinMoin.datastruct.backends.config_lazy_groups']
-

MoinMoin/datastruct/backends/_tests/test_wiki_dicts.py

         assert result == expected
 
 coverage_modules = ['MoinMoin.datastruct.backends.wiki_dicts']
-

MoinMoin/datastruct/backends/_tests/test_wiki_groups.py

         assert has_rights_after, 'AnotherUser must have read rights because after appenditem he is member of NewGroup'
 
 coverage_modules = ['MoinMoin.datastruct.backends.wiki_groups']
-

MoinMoin/datastruct/backends/composite_dicts.py

 
     def __repr__(self):
         return "<{0} backends={1}>".format(self.__class__, self._backends)
-

MoinMoin/datastruct/backends/composite_groups.py

 
     def __repr__(self):
         return "<{0} backends={1}>".format(self.__class__, self._backends)
-

MoinMoin/datastruct/backends/config_dicts.py

             return self._dicts[dict_name]
         except KeyError:
             raise DictDoesNotExistError(dict_name)
-

MoinMoin/datastruct/backends/config_groups.py

             return self._groups[group_name]
         except KeyError:
             raise GroupDoesNotExistError(group_name)
-

MoinMoin/datastruct/backends/config_lazy_groups.py

 
     def _group_has_member(self, group_name, member):
         return group_name in self and member in self._groups[group_name]
-

MoinMoin/datastruct/backends/wiki_dicts.py

         rev = item.get_revision(CURRENT)
         somedict = rev.meta.get(SOMEDICT, {})
         return somedict
-

MoinMoin/datastruct/backends/wiki_groups.py

         rev = item[CURRENT]
         usergroup = rev.meta.get(USERGROUP, [])
         return usergroup
-

MoinMoin/error.py

 
 class InternalError(FatalError):
     """ Raise when internal fatal error is found """
-

MoinMoin/i18n/__init__.py

     u = getattr(flaskg, 'user', None)
     if u and u.timezone is not None:
         return u.timezone
-

MoinMoin/i18n/_tests/test_i18n.py

     assert result1 == 'text1'
     result2 = N_('text1', 'text2', 2)
     assert result2 == 'text2'
-

MoinMoin/items/__init__.py

+# Copyright: 2012 MoinMoin:CheerXiao
 # Copyright: 2009 MoinMoin:ThomasWaldmann
 # Copyright: 2009-2011 MoinMoin:ReimarBauer
 # Copyright: 2009 MoinMoin:ChristopherDenter
 from MoinMoin.util.interwiki import url_for_item
 from MoinMoin.storage.error import NoSuchItemError, NoSuchRevisionError, StorageError
 from MoinMoin.config import NAME, NAME_OLD, NAME_EXACT, WIKINAME, MTIME, REVERTED_TO, ACL, \
-                            IS_SYSITEM, SYSITEM_VERSION,  USERGROUP, SOMEDICT, \
+                            IS_SYSITEM, SYSITEM_VERSION, USERGROUP, SOMEDICT, \
                             CONTENTTYPE, SIZE, LANGUAGE, ITEMLINKS, ITEMTRANSCLUSIONS, \
                             TAGS, ACTION, ADDRESS, HOSTNAME, USERID, EXTRA, COMMENT, \
                             HASH_ALGORITHM, CONTENTTYPE_GROUPS, ITEMID, REVID, DATAID, \
         if not flaskg.user.may.create(self.name):
             abort(403)
 
-        # XXX think about and add item template support
         return render_template('modify_show_type_selection.html',
                                item_name=self.name,
                                contenttype_groups=CONTENTTYPE_GROUPS,
         revs = flaskg.storage.search(query, sortedby=NAME_EXACT, limit=None)
         return [rev.meta[NAME] for rev in revs]
 
+    from MoinMoin.apps.frontend.views import CommentForm
+    class ModifyForm(CommentForm):
+        """Base class for ModifyForm of Binary's subclasses."""
+        meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON())
+        data_file = FileStorage.using(optional=True, label=L_('Upload file:'))
+
+        def _load(self):
+            item = self.item
+            self['meta_text'] = item.meta_dict_to_text(item.prepare_meta_for_modify(item.meta))
+
+        extra_template_args = {}
+
+        @classmethod
+        def from_item(cls, item):
+            method = request.method
+            if method == 'GET':
+                form = cls.from_defaults()
+                TextCha(form).amend_form()
+                form.item = item
+                form._load()
+            elif method == 'POST':
+                form = cls.from_flat(request.form.items() + request.files.items())
+                form.item = item
+                TextCha(form).amend_form()
+                form.validate()
+            else:
+                raise ValueError("Request method '%s' not supported" % method)
+            return form
+
     def do_modify(self, contenttype, template_name):
-        # XXX think about and add item template support
-        #if template_name is None and isinstance(self.rev, DummyRev):
-        #    return self._do_modify_show_templates()
-        from MoinMoin.apps.frontend.views import CommentForm
-        class ModifyForm(CommentForm):
-            meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON())
-            data_file = FileStorage.using(optional=True, label=L_('Upload file:'))
+        method = request.method
+        if method == 'GET' and template_name is None and isinstance(self.rev, DummyRev):
+            return self._do_modify_show_templates()
 
-        if request.method == 'GET':
-            form = ModifyForm.from_defaults()
-            TextCha(form).amend_form()
-            form['meta_text'] = self.meta_dict_to_text(self.prepare_meta_for_modify(self.meta))
-        elif request.method == 'POST':
-            form = ModifyForm.from_flat(request.form.items() + request.files.items())
-            TextCha(form).amend_form()
-            if form.validate():
-                try:
-                    self.modify() # XXX
-                except AccessDenied:
-                    abort(403)
-                else:
-                    return redirect(url_for_item(self.name))
+        if template_name:
+            item = Item.create(template_name)
+
+        form = self.ModifyForm.from_item(self)
+        if method == 'POST' and form.validate():
+            try:
+                self.modify() # XXX
+            except AccessDenied:
+                abort(403)
+            else:
+                return redirect(url_for_item(self.name))
         return render_template(self.template,
                                item_name=self.name,
                                rows_meta=str(ROWS_META), cols=str(COLS),
                                help=self.modify_help,
                                form=form,
                                search_form=None,
+                               **form.extra_template_args
                               )
 
     def _render_data_diff(self, oldrev, newrev):
     """ Base class for text/* """
     template = "modify_text.html"
 
+    class ModifyForm(Binary.ModifyForm):
+        data_text = String.using(strip=False, optional=True).with_properties(placeholder=L_("Type your text here"))
+
+        def _load(self):
+            super(Text.ModifyForm, self)._load()
+            item = self.item
+            self['data_text'] = item.data_storage_to_internal(item.data)
+
+        extra_template_args = {'rows_data': str(ROWS_DATA)}
+
     # text/plain mandates crlf - but in memory, we want lf only
     def data_internal_to_form(self, text):
         """ convert data from memory format to form format """
         doc = html_conv(doc)
         return conv_serialize(doc, {html.namespace: ''})