Anonymous avatar Anonymous committed d820478

Simplewiki is now upgraded to latest creoleparser, Genshi and SQLAlchemy

Comments (0)

Files changed (3)

examples/simplewiki/actions.py

             change_note = request.form.get('change_note', '')
             if page is None:
                 page = Page(page_name)
-            revision = Revision(page, text, change_note)
+                session.add(page)
+            session.add(Revision(page, text, change_note))
             session.commit()
             return redirect(href(page.name))
 
                     change_note = request.form.get('change_note', '')
                     change_note = 'revert' + (change_note and ': ' +
                                               change_note or '')
-                    revision = Revision(page, old_revision.text,
-                                        change_note)
+                    session.add(Revision(page, old_revision.text,
+                                         change_note))
                     session.commit()
                     return redirect(href(page_name))
 

examples/simplewiki/database.py

 from datetime import datetime
 from sqlalchemy import Table, Column, Integer, String, DateTime, \
      ForeignKey, MetaData, join
-from sqlalchemy.orm import relation, create_session, scoped_session
+from sqlalchemy.orm import relation, create_session, scoped_session, \
+     mapper
 from simplewiki.utils import application, local_manager, parse_creole
 
 
     new revisions.  It's also used for the diff system and the revision
     log.
     """
+    query = session.query_property()
 
     def __init__(self, page, text, change_note='', timestamp=None):
         if isinstance(page, (int, long)):
     Represents a simple page without any revisions.  This is for example
     used in the page index where the page contents are not relevant.
     """
+    query = session.query_property()
 
     def __init__(self, name):
         self.name = name
     and the ability of SQLAlchemy to map to joins we can combine `Page` and
     `Revision` into one class here.
     """
+    query = session.query_property()
 
     def __init__(self):
         raise TypeError('cannot create WikiPage instances, use the Page and '
 
 
 # setup mappers
-session.mapper(Revision, revision_table)
-session.mapper(Page, page_table, properties=dict(
+mapper(Revision, revision_table)
+mapper(Page, page_table, properties=dict(
     revisions=relation(Revision, backref='page',
                        order_by=Revision.revision_id.desc())
 ))
-session.mapper(RevisionedPage, join(page_table, revision_table), properties=dict(
+mapper(RevisionedPage, join(page_table, revision_table), properties=dict(
     page_id=[page_table.c.page_id, revision_table.c.page_id],
 ))

examples/simplewiki/utils.py

     :license: BSD.
 """
 import difflib
+import creoleparser
 from os import path
 from genshi import Stream
 from genshi.template import TemplateLoader
-from creoleparser import Parser, Creole10
 from werkzeug import BaseRequest, BaseResponse, Local, LocalManager, \
      url_encode, url_quote, redirect, cached_property
 
 application = local('application')
 
 # create a new creole parser
-creole_parser = Parser(dialect=Creole10(
-    wiki_links_base_url='',
-    wiki_links_path_func=lambda page_name: href(page_name),
-    wiki_links_space_char='_',
-    no_wiki_monospace=True,
-    use_additions=True
-))
+creole_parser = creoleparser.Parser(
+    dialect=creoleparser.create_dialect(creoleparser.creole10_base,
+        wiki_links_base_url='',
+        wiki_links_path_func=lambda page_name: href(page_name),
+        wiki_links_space_char='_',
+        no_wiki_monospace=True
+    ),
+    method='html'
+)
 
 
 def generate_template(template_name, **context):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.