Commits

Nozomu Kaneko committed f5caeee

update patches

Comments (0)

Files changed (3)

 rename to quickwiki/views/pages.py
 --- a/quickwiki/controllers/pages.py
 +++ b/quickwiki/views/pages.py
-@@ -1,69 +1,96 @@
+@@ -1,69 +1,98 @@
  import logging
  from cgi import escape
  
  
  log = logging.getLogger(__name__)
  
++class NewPage(Exception):
++    pass
++
 -class PagesController(BaseController):
--    
++class PagesHandler(object):
+     
 -    def __before__(self):
 -        self.page_q = Session.query(Page)
--    
++    def __init__(self, request):
++        self.request = request
++        self.page_q = DBSession.query(Page)
+     
 -    def show(self, title):
 -        page = self.page_q.filter_by(title=title).first()
 -        c.title = title
 -        elif wikiwords.match(title):
 -            return render('/pages/new.mako')
 -        abort(404)
--    
--    def edit(self, title):
--        c.title = title
--        c.content = u''
-+class NewPage(Exception):
-+    pass
-+
-+class PagesController(object):
-+
-+    def __init__(self, request):
-+        self.request = request
-+        self.page_q = DBSession.query(Page)
-+
 +    @view_config(route_name="home", renderer='pages/show.mako')
 +    @view_config(route_name="page", renderer='pages/show.mako')
 +    @view_config(route_name="show_page", renderer='pages/show.mako')
 +            title = "FrontPage"
 +        else:
 +            title = self.request.matchdict["title"]
-         page = self.page_q.filter_by(title=title).first()
-         if page:
--            c.title = page.title
--            c.content = page.content
--        return render('/pages/edit.mako')
--    
--    @authenticate_form
--    def save(self, title):
--        c.title = title
++        page = self.page_q.filter_by(title=title).first()
++        if page:
 +            return {
 +                "title": title,
 +                "content": page.get_wiki_content(self.request),
 +        return {
 +            "title": title,
 +            }
-+
+     
+-    def edit(self, title):
+-        c.title = title
+-        c.content = u''
+-        page = self.page_q.filter_by(title=title).first()
+-        if page:
+-            c.title = page.title
+-            c.content = page.content
+-        return render('/pages/edit.mako')
 +    @view_config(route_name="edit_page", renderer='pages/edit.mako')
 +    def edit(self):
 +        title = self.request.matchdict["title"]
 +                "title": title,
 +                "content": u'',
 +                }
-+
+     
+-    @authenticate_form
+-    def save(self, title):
+-        c.title = title
 +    @view_config(route_name="save_page", request_method="POST")
 +    # @authenticate_form
 +    def save(self):
 -        Session.commit()
 -        flash('Successfully saved %s!' % title)
 -        redirect(url('show_page', title=title))
--    
 +        page.content = escape(self.request.POST.getone('content'))
 +        with transaction.manager:
 +            DBSession.add(page)
 +        self.request.session.flash('Successfully saved %s!' % title)
 +        raise exc.HTTPFound(self.request.route_url("show_page", title=title))
-+
+     
 +    @view_config(route_name="pages", renderer='pages/index.mako')
      def index(self):
 -        c.titles = [page.title for page in self.page_q.all()]
 -        return render('/pages/index.mako')
--    
--    @authenticate_form
 +        return {
 +            "titles": [page.title for page in self.page_q.all()],
 +            }
-+
+     
+-    @authenticate_form
 +    @view_config(route_name="delete_page", request_method="POST")
 +    # @authenticate_form
      def delete(self):
          for title in titles:
 -            flash('Deleted %s.' % title)
 -        redirect(url('pages'))
--    
--
 +            self.request.session.flash('Deleted %s.' % title)
 +        raise exc.HTTPFound(self.request.route_url("pages"))
+     
+ 

static_views.diff

 # HG changeset patch
-# Parent f63ab4a5f5bf0444354e0e4f4da27663f2cb5a22
+# Parent e5c2d0248c3f598855a7258567c17a32f74ae3a4
 
 diff --git a/quickwiki/__init__.py b/quickwiki/__init__.py
 --- a/quickwiki/__init__.py
  
  def make_route(config):
 +    config.add_route('catchall_static', '/*subpath',
-+                     path_info=r"/(?:favicon\.ico|quick.css)")
++                     path_info=r"/(?:favicon\.ico|quick\.css)")
 +
      config.add_route('home', '/')
      config.add_route('pages', '/pages')
  
  log = logging.getLogger(__name__)
  
--def setup_app(command, conf, vars):
--    """Place any commands to setup {{package}} here"""
--    # Don't reload the app if it was loaded under the testing environment
--    if not pylons.test.pylonsapp:
--        load_environment(conf.global_conf, conf.local_conf)
--    
 +def usage(argv):
 +    cmd = os.path.basename(argv[0])
 +    print('usage: %s <config_uri>\n'
 +          '(example: "%s development.ini")' % (cmd, cmd))
 +    sys.exit(1)
 +
+-def setup_app(command, conf, vars):
+-    """Place any commands to setup {{package}} here"""
+-    # Don't reload the app if it was loaded under the testing environment
+-    if not pylons.test.pylonsapp:
+-        load_environment(conf.global_conf, conf.local_conf)
 +def main(argv=sys.argv):
 +    if len(argv) != 2:
 +        usage(argv)
 +    settings = get_appsettings(config_uri)
 +    engine = engine_from_config(settings, 'sqlalchemy.')
 +    DBSession.configure(bind=engine)
-+
+     
      # Create the tables if they don't already exist
      log.info("Creating tables...")
 -    Base.metadata.create_all(bind=Session.bind)