Commits

pjenvey  committed a04fede

[svn] merge from tags/0.1.5@2379, r2366:2379

  • Participants
  • Parent commits f946d40
  • Tags v0.1.5

Comments (0)

Files changed (18)

File quickwiki/config/environment.py

 from quickwiki.config.routing import make_map
 
 def load_environment(global_conf, app_conf):
-    """Configure the Pylons environment via the ``pylons.config`` object"""
+    """Configure the Pylons environment via the ``pylons.config``
+    object
+    """
     # Pylons paths
     root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
     paths = dict(root=root,
     # Customize templating options via this variable
     tmpl_options = config['buffet.template_options']
 
-    # CONFIGURATION OPTIONS HERE (note: all config options will override any
-    # Pylons config options)
-    config['pylons.g'].sa_engine = engine_from_config(config, 'sqlalchemy.default.')
+    # CONFIGURATION OPTIONS HERE (note: all config options will override
+    # any Pylons config options)
+    config['pylons.g'].sa_engine = engine_from_config(config,
+                                                      'sqlalchemy.default.')

File quickwiki/config/middleware.py

     """Create a Pylons WSGI application and return it
 
     ``global_conf``
-        The inherited configuration for this application. Normally from the
-        [DEFAULT] section of the Paste ini file.
+        The inherited configuration for this application. Normally from
+        the [DEFAULT] section of the Paste ini file.
 
     ``full_stack``
-        Whether or not this application provides a full WSGI stack (by default,
-        meaning it handles its own exceptions and errors). Disable full_stack
-        when this application is "managed" by another WSGI middleware.
+        Whether or not this application provides a full WSGI stack (by
+        default, meaning it handles its own exceptions and errors).
+        Disable full_stack when this application is "managed" by
+        another WSGI middleware.
 
     ``app_conf``
         The application's local configuration. Normally specified in the
-        [app:<name>] section of the Paste ini file (where <name> defaults to
-        main).
+        [app:<name>] section of the Paste ini file (where <name>
+        defaults to main).
     """
     # Configure the Pylons environment
     load_environment(global_conf, app_conf)
     # The Pylons WSGI app
     app = PylonsApp()
 
-    # CUSTOM MIDDLEWARE HERE (filtered by the error handling middlewares)
+    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
 
     if asbool(full_stack):
         # Handle Python exceptions
         app = ErrorHandler(app, global_conf, error_template=error_template,
                            **config['pylons.errorware'])
 
-        # Display error documents for 401, 403, 404 status codes (and 500 when
-        # debug is disabled)
+        # Display error documents for 401, 403, 404 status codes (and
+        # 500 when debug is disabled)
         app = ErrorDocuments(app, global_conf, mapper=error_mapper, **app_conf)
 
     # Establish the Registry for this application

File quickwiki/config/routing.py

 """Routes configuration
 
-The more specific and detailed routes should be defined first so they may take
-precedent over the more generic routes. For more information refer to the
-routes manual at http://routes.groovie.org/docs/
+The more specific and detailed routes should be defined first so they
+may take precedent over the more generic routes. For more information
+refer to the routes manual at http://routes.groovie.org/docs/
 """
 from pylons import config
 from routes import Mapper
     map = Mapper(directory=config['pylons.paths']['controllers'],
                  always_scan=config['debug'])
 
-    # The ErrorController route (handles 404/500 error pages); it should likely
-    # stay at the top, ensuring it can always be resolved
+    # The ErrorController route (handles 404/500 error pages); it should
+    # likely stay at the top, ensuring it can always be resolved
     map.connect('error/:action/:id', controller='error')
 
     # CUSTOM ROUTES HERE
 
-    map.connect(':controller/:action/:title', controller='page', action='index', title='FrontPage')
+    map.connect(':controller/:action/:title', controller='page',
+                action='index', title='FrontPage')
     map.connect(':title', controller='page', action='index', title='FrontPage')
     map.connect('*url', controller='template', action='view')
 

File quickwiki/controllers/error.py

         return self._serve_file(os.path.join(media_path, 'style', id))
 
     def _serve_file(self, path):
-        """Call Paste's FileApp (a WSGI application) to serve the file at the
-        specified path
+        """Call Paste's FileApp (a WSGI application) to serve the file
+        at the specified path
         """
         fapp = paste.fileapp.FileApp(path)
         return fapp(request.environ, self.start_response)

File quickwiki/controllers/page.py

 import logging
 
 from quickwiki.lib.base import *
-from quickwiki.model import Session, Page
+from quickwiki.model import Page
 
 log = logging.getLogger(__name__)
 
 class PageController(BaseController):
-    
+
     def index(self, title):
         page_q = Session.query(Page)
         page = page_q.filter_by(title=title).first()
         if page:
             c.content = page.content
         return render('/edit.mako')
-        
+
     def save(self, title):
         page_q = Session.query(Page)
         page = page_q.filter_by(title=title).first()

File quickwiki/controllers/template.py

 class TemplateController(BaseController):
 
     def view(self, url):
-        """By default, the final controller tried to fulfill the request when
-        no other routes match. It may be used to display a template when all
-        else fails, e.g.::
+        """By default, the final controller tried to fulfill the request
+        when no other routes match. It may be used to display a template
+        when all else fails, e.g.::
 
             def view(self, url):
                 return render('/%s' % url)
 
-        Or if you're using Mako and want to explicitly send a 404 (Not Found)
-        response code when the requested template doesn't exist::
+        Or if you're using Mako and want to explicitly send a 404 (Not
+        Found) response code when the requested template doesn't exist::
 
             import mako.exceptions
 
                 except mako.exceptions.TopLevelLookupException:
                     abort(404)
 
-        By default this controller aborts the request with a 404 (Not Found)
+        By default this controller aborts the request with a 404 (Not
+        Found)
         """
         abort(404)

File quickwiki/lib/app_globals.py

 from pylons import config
 
 class Globals(object):
-    """Globals acts as a container for objects available throughout the life of
-    the application.
+    """Globals acts as a container for objects available throughout the
+    life of the application
     """
 
     def __init__(self):
-        """One instance of Globals is created during application initialization
-        and is available during requests via the 'g' variable.
+        """One instance of Globals is created during application
+        initialization and is available during requests via the 'g'
+        variable
         """
         pass

File quickwiki/lib/base.py

 """The base Controller API
 
-Provides the BaseController class for subclassing, as well as functions and
-objects for use by Controllers.
+Provides the BaseController class for subclassing, and other objects
+utilized by Controllers.
 """
 from pylons import c, cache, config, g, request, response, session
 from pylons.controllers import WSGIController
 
 import quickwiki.lib.helpers as h
 import quickwiki.model as model
+from quickwiki.model import Session
 
 class BaseController(WSGIController):
 
     def __call__(self, environ, start_response):
         """Invoke the Controller"""
-        # WSGIController.__call__ dispatches to the Controller method the
-        # request is routed to. This routing information is available in
-        # environ['pylons.routes_dict']
+        # WSGIController.__call__ dispatches to the Controller method
+        # the request is routed to. This routing information is
+        # available in environ['pylons.routes_dict']
         try:
             return WSGIController.__call__(self, environ, start_response)
         finally:
-            model.Session.remove()
+            Session.remove()
 
 # Include the '_' function in the public names
 __all__ = [__name for __name in locals().keys() if not __name.startswith('_') \

File quickwiki/lib/helpers.py

 """Helper functions
 
-Consists of functions to typically be used within templates, but also available
-to Controllers. This module is available to both as 'h'.
+Consists of functions to typically be used within templates, but also
+available to Controllers. This module is available to both as 'h'.
 """
 from webhelpers import *

File quickwiki/model/__init__.py

+import re
+import sets
+
+from docutils.core import publish_parts
 from pylons import config
 from sqlalchemy import Column, MetaData, Table, types
-from sqlalchemy.orm import mapper, relation
+from sqlalchemy.orm import mapper
 from sqlalchemy.orm import scoped_session, sessionmaker
 
-import re
-import sets
 import quickwiki.lib.helpers as h
-from docutils.core import publish_parts
 
 # Global session manager for SQLAlchemy. Session() returns the session
 # object appropriate for the current web request.
-Session = scoped_session(sessionmaker(autoflush=True,
-                         transactional=True, bind=config['pylons.g'].sa_engine))
+Session = scoped_session(sessionmaker(autoflush=True, transactional=True,
+                                      bind=config['pylons.g'].sa_engine))
 
-# Global metadata. If you have multiple databases with overlapping 
+# Global metadata. If you have multiple databases with overlapping
 # table names, you'll need a metadata for each database.
 metadata = MetaData()
 
         content = publish_parts(self.content, writer_name="html")["html_body"]
         titles = sets.Set(wikiwords.findall(content))
         for title in titles:
-            title_url = h.url_for(controller='page', action='index', 
+            title_url = h.url_for(controller='page', action='index',
                                   title=title)
             content = content.replace(title, h.link_to(title, title_url))
         return content
-                    
+
 mapper(Page, pages_table)

File quickwiki/templates/base.mako

-# -*- coding: utf-8 -*-
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html>
-<head>
-  <title>QuickWiki</title>
-  ${h.stylesheet_link_tag('/quick.css')}
-  ${h.javascript_include_tag('/javascripts/effects.js', builtins=True)}
-</head>
-<body>
-  <div class="content">
-    ${next.body()}\
-    <p class="footer">
-    ${footer(request.environ['pylons.routes_dict']['action'])}\
-    </p>
-  </div>
-</body>
+  <head>
+    <title>QuickWiki</title>
+    ${h.stylesheet_link_tag('/quick.css')}
+    ${h.javascript_include_tag('/javascripts/effects.js', builtins=True)}
+  </head>
+  <body>
+    <div class="content">
+      ${next.body()}\
+      <p class="footer">
+      ${footer(request.environ['pylons.routes_dict']['action'])}\
+      </p>
+    </div>
+  </body>
 </html>
 
 ## Don't show links that are redundant for particular pages
     | ${h.link_to('Edit '+c.title, h.url_for(title=c.title, action='edit'))}
   % endif
   | ${h.link_to('Title List', h.url_for(action='list', title=None))}
-</%def>
+</%def>

File quickwiki/templates/list-titles.mako

   &nbsp;[${h.link_to('visit', h.url_for(title=title, action="index"))}]
   ${h.draggable_element("page-"+ str(title), revert=True)}
 </li>
-% endfor
+% endfor

File quickwiki/templates/new_page.mako

 
 <h1 class="main">${c.title}</h1>
 <p>This page doesn't exist yet.
-  <a href="${h.url_for(action='edit', title=c.title)}">Create the page</a>.</p>
+  <a href="${h.url_for(action='edit', title=c.title)}">Create the page</a>.
+</p>

File quickwiki/templates/page.mako

-<%inherit file="base.mako"/>\
+<%inherit file="base.mako"/>
 
 <h1 class="main">${c.title}</h1>
 % if c.message:
 <p><div id="message">${c.message}</div></p>
 % endif
-${c.content}
+${c.content}

File quickwiki/tests/__init__.py

 """Pylons application test package
 
-When the test runner finds and executes tests within this directory, this file
-will be loaded to setup the test environment.
+When the test runner finds and executes tests within this directory,
+this file will be loaded to setup the test environment.
 
-It registers the root directory of the project in sys.path and pkg_resources,
-in case the project hasn't been installed with setuptools. It also initializes
-the application via websetup (paster setup-app) with the project's test.ini
-configuration file.
+It registers the root directory of the project in sys.path and
+pkg_resources, in case the project hasn't been installed with
+setuptools. It also initializes the application via websetup (paster
+setup-app) with the project's test.ini configuration file.
 """
 import os
 import sys

File quickwiki/tests/functional/test_page.py

 class TestPageController(TestController):
     def test_index(self):
         response = self.app.get(url_for(controller='page'))
-        # Test response...
+        # Test response...

File quickwiki/websetup.py

     # Populate the DB on 'paster setup-app'
     import quickwiki.model as model
 
-    print "Setting up database connectivity..."
+    log.info("Setting up database connectivity...")
     engine = config['pylons.g'].sa_engine
-    print "Creating tables..."
+    log.info("Creating tables...")
     model.metadata.create_all(bind=engine)
-    print "Successfully set up."
+    log.info("Successfully set up.")
 
-    print "Adding front page data..."
+    log.info("Adding front page data...")
     page = model.Page()
     page.title = 'FrontPage'
     page.content = 'Welcome to the QuickWiki front page.'
     model.Session.save(page)
     model.Session.commit()
-    print "Successfully set up."
+    log.info("Successfully set up.")
     include_package_data=True,
     test_suite='nose.collector',
     package_data={'quickwiki': ['i18n/*/LC_MESSAGES/*.mo']},
-    message_extractors = {'quickwiki': [
-            ('**.py', 'python', None),
-            ('templates/**.mako', 'mako', None),
-            ('public/**', 'ignore', None)]},
+    #message_extractors = {'quickwiki': [
+    #        ('**.py', 'python', None),
+    #        ('templates/**.mako', 'mako', None),
+    #        ('public/**', 'ignore', None)]},
     entry_points="""
     [paste.app_factory]
     main = quickwiki.config.middleware:make_app