Commits

Ches Martin committed dd606c5

more work in progress, to fold together later

Comments (0)

Files changed (5)

+remove egg-info since we've moved to deployment.ini_tmpl in app/config; hgignore it
+
+diff --git a/.hgignore b/.hgignore
+--- a/.hgignore
++++ b/.hgignore
+@@ -2,6 +2,7 @@
+ .svn
+ .coverage
+ *.pyc
++*.egg-info/
+ *.egg-link
+ .DS_Store
+ ez_setup
+diff --git a/QuickWiki.egg-info/paste_deploy_config.ini_tmpl b/QuickWiki.egg-info/paste_deploy_config.ini_tmpl
+deleted file mode 100644
+--- a/QuickWiki.egg-info/paste_deploy_config.ini_tmpl
++++ /dev/null
+@@ -1,64 +0,0 @@
+-#
+-# QuickWiki - Pylons configuration
+-#
+-# The %(here)s variable will be replaced with the parent directory of this file
+-#
+-[DEFAULT]
+-debug = true
+-email_to = you@yourdomain.com
+-smtp_server = localhost
+-error_email_from = paste@localhost
+-
+-[server:main]
+-use = egg:Paste#http
+-host = 0.0.0.0
+-port = 5000
+-
+-[app:main]
+-use = egg:QuickWiki
+-full_stack = true
+-cache_dir = %(here)s/data
+-beaker.session.key = quickwiki
+-beaker.session.secret = ${app_instance_secret}
+-app_instance_uuid = ${app_instance_uuid}
+-
+-# Specify the database for SQLAlchemy to use.
+-# %(here) may include a ':' character on Windows environments; this can
+-# invalidate the URI when specifying a SQLite db via path name
+-#sqlalchemy.default.url = sqlite:///%(here)s/quickwiki.db
+-#sqlalchemy.echo = true
+-
+-# If you'd like to fine-tune the individual locations of the cache data dirs
+-# for the Cache data, or the Session saves, un-comment the desired settings
+-# here:
+-#beaker.cache.data_dir = %(here)s/data/cache
+-#beaker.session.data_dir = %(here)s/data/sessions
+-
+-# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
+-# Debug mode will enable the interactive debugging tool, allowing ANYONE to
+-# execute malicious code after an exception is raised.
+-set debug = false
+-
+-
+-# Logging configuration
+-[loggers]
+-keys = root
+-
+-[handlers]
+-keys = console
+-
+-[formatters]
+-keys = generic
+-
+-[logger_root]
+-level = INFO
+-handlers = console
+-
+-[handler_console]
+-class = StreamHandler
+-args = (sys.stderr,)
+-level = NOTSET
+-formatter = generic
+-
+-[formatter_generic]
+-format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s
+use an `__init__` method on the model
+diff --git a/quickwiki/controllers/pages.py b/quickwiki/controllers/pages.py
+--- a/quickwiki/controllers/pages.py
++++ b/quickwiki/controllers/pages.py
+@@ -31,11 +31,10 @@
+     def save(self, title):
+         page = self.page_q.filter_by(title=title).first()
+         if not page:
+-            page = Page()
+-            page.title = title
++            page = Page(title)
+         # In a real application, you should validate and sanitize
+         # submitted data throughly! escape is a minimal example here.
+-        page.content = escape(request.POST.get('content', ''))
++        page.content = escape(request.POST.getone('content'))
+         DBSession.add(page)
+         DBSession.commit()
+         flash('Successfully saved %s!' % title)
+@@ -54,6 +53,5 @@
+         page = self.page_q.filter_by(title=title).one()
+         DBSession.delete(page)
+         DBSession.commit()
+-        c.titles = self.page_q.all()
+         flash('Deleted %s.' % title)
+         redirect_to('pages')
+diff --git a/quickwiki/model/__init__.py b/quickwiki/model/__init__.py
+--- a/quickwiki/model/__init__.py
++++ b/quickwiki/model/__init__.py
+@@ -8,12 +8,12 @@
+ from sqlalchemy import orm
+ 
+ from pylons import url
++from quickwiki.lib.helpers import link_to
+ from quickwiki.model import meta
+-import quickwiki.lib.helpers as h
+ 
+ 
+-docutils_safety = {'file_insertion_enabled': False, 'raw_enabled': False}
+ log = logging.getLogger(__name__)
++SAFE_DOCUTILS = {'file_insertion_enabled': False, 'raw_enabled': False}
+ wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)", re.UNICODE)
+ 
+ def init_model(engine):
+@@ -30,14 +30,15 @@
+ )
+ 
+ class Page(object):
+-    content = None
+-
+-    def __str__(self):
+-        return self.title
++    def __init__(self, title, content=None):
++        self.title = title
++        self.content = content
+ 
+     @orm.validates('title')
+     def validate_title(self, key, title):
+-        """Assure that page titles are wikiwords"""
++        """Assure that page titles are wikiwords and valid length."""
++        if len(title) > 40:
++            raise ValueError("Page title must be 40 characters or fewer")
+         if wikiwords.match(title) is None:
+             log.warning("%s: invalid title (%s)" % (self.__class__.__name__,
+                                                     title))
+@@ -49,11 +50,19 @@
+         create links for WikiWords.
+         """
+         content = publish_parts(self.content, writer_name='html',
+-                                settings_overrides=docutils_safety)['html_body']
++                                settings_overrides=SAFE_DOCUTILS)['html_body']
+         titles = sets.Set(wikiwords.findall(content))
+         for title in titles:
+             title_url = url(controller='pages', action='show', title=title)
+-            content = content.replace(title, h.link_to(title, title_url))
++            content = content.replace(title, link_to(title, title_url))
+         return content
+ 
++    def __unicode__(self):
++        return self.title
++
++    __str__ = __unicode__
++    
++    def __repr__(self):
++        return "<Page('%s', '%s')>" % (self.title, self.content)
++
+ orm.mapper(Page, pages_table)
+diff --git a/quickwiki/websetup.py b/quickwiki/websetup.py
+--- a/quickwiki/websetup.py
++++ b/quickwiki/websetup.py
+@@ -20,9 +20,10 @@
+     
+     import quickwiki.model as model
+     log.info("Adding front page data...")
+-    page = model.Page()
+-    page.title = u'FrontPage'
+-    page.content = u'Welcome to the QuickWiki front page.'
++    page = model.Page(
++        title = u'FrontPage',
++        content = u'Welcome to the QuickWiki front page.'
++        )
+     meta.Session.add(page)
+     meta.Session.commit()
+     log.info("Successfully set up.")

quickwiki-097.patch

 diff --git a/.hgignore b/.hgignore
 --- a/.hgignore
 +++ b/.hgignore
-@@ -1,14 +1,17 @@
+@@ -1,6 +1,7 @@
  syntax:glob
  .svn
  .coverage
 +*.db
  *.pyc
+ *.egg-info/
  *.egg-link
-+*.egg-info/
- .DS_Store
- ez_setup
- container_file
+@@ -10,6 +11,7 @@
  container_dbm*
  *~
  build/
 diff --git a/development.ini b/development.ini
 --- a/development.ini
 +++ b/development.ini
-@@ -12,21 +12,17 @@
+@@ -12,28 +12,27 @@
  
  [server:main]
  use = egg:Paste#http
  cache_dir = %(here)s/data
  beaker.session.key = quickwiki
  beaker.session.secret = somesecret
--
+ 
 -# Specify the database for SQLAlchemy to use.
 -# %(here) may include a ':' character on Windows environments; this can
 -# invalidate the URI when specifying a SQLite db via path name
 -sqlalchemy.default.url = sqlite:///%(here)s/quickwiki.db
 -sqlalchemy.echo = true
- 
+-
  # If you'd like to fine-tune the individual locations of the cache data dirs
  # for the Cache data, or the Session saves, un-comment the desired settings
-@@ -34,6 +30,9 @@
+ # here:
  #beaker.cache.data_dir = %(here)s/data/cache
  #beaker.session.data_dir = %(here)s/data/sessions
  
  
  [handlers]
  keys = console
-@@ -54,10 +53,24 @@
+@@ -54,11 +53,25 @@
  level = INFO
  handlers = console
  
  level = DEBUG
  handlers =
  qualname = quickwiki
-+
+ 
 +[logger_sqlalchemy]
 +level = INFO
 +handlers =
 +# "level = INFO" logs SQL queries.
 +# "level = DEBUG" logs SQL queries and results.
 +# "level = WARN" logs neither.  (Recommended for production systems.)
- 
++
  [handler_console]
  class = StreamHandler
+ args = (sys.stderr,)
 diff --git a/docs/index.txt b/docs/index.txt
 --- a/docs/index.txt
 +++ b/docs/index.txt
 @@ -1,31 +1,28 @@
  """Setup the QuickWiki application"""
  import logging
--
+ 
 -from paste.deploy import appconfig
 -from pylons import config
- 
+-
  from quickwiki.config.environment import load_environment
  
  log = logging.getLogger(__name__)
+egg-info.patch
 quickwiki-097.patch
+model_init.patch
+temp-version.patch

temp-version.patch

+temp version bump for working dev
+diff --git a/setup.py b/setup.py
+--- a/setup.py
++++ b/setup.py
+@@ -13,7 +13,7 @@
+     #author_email='',
+     url='http://docs.pylonshq.com/tutorials/quickwiki_tutorial.html',
+     install_requires=[
+-        "Pylons>=0.9.7",
++        "Pylons==0.9.7dev_20081231",
+         "SQLAlchemy==0.5.0rc4",
+         "docutils==0.4"
+     ],