September 06, 2010
QuickWiki is the standard introductory Pylons tutorial project. In this template, the Page model is expressed in Elixir.
Note
shabti_quickwiki source code is in the bitbucket code repository
Here is the Page model in vanilla SQLA.
pages_table = Table('pages', metadata,
Column('title', types.String(40), primary_key=True),
Column('content', types.String(), default='')
)
class Page(object):
content = None
def __str__(self):
return self.title
def get_wiki_content(self):
content = publish_parts(self.content,
writer_name="html")["html_body"]
titles = sets.Set(wikiwords.findall(content))
for title in titles:
title_url = h.url(controller='page',
action='index',
title=title)
content = content.replace(title,
h.link_to(title, title_url))
return content
mapper(Page, pages_table)
In this template, it is expressed in Elixir DSL:
class Page(Entity):
title = Field(Unicode, primary_key=True)
content = Field(Unicode, default='')
def __str__(self):
return self.title
def get_wiki_content(self):
content = publish_parts(self.content,
writer_name="html")["html_body"]
titles = sets.Set(wikiwords.findall(content))
for title in titles:
title_url = h.url(controller='page',
action='index',
title=title)
content = content.replace(title,
h.link_to(title, title_url))
return content
Dependencies for this template are SQLAlchemy>=0.5 and Elixir>=0.6.1.
After successfully installing Shabti, additional paster templates will be available. Simply create a Shabti-configured project by specifying that paster should use the shabti_quickwiki template:
$ paster create -t shabti_quickwiki myproj
These are the option dialogue choices appropriate for the Shabti quickwiki template — which uses mako templates and SQLAlchemy ...
(mako/genshi/jinja/etc: Template language) ['mako']:
(True/False: Include SQLAlchemy 0.4 configuration) [False]: True
(True/False: Setup default appropriate for Google App Engine) [False]:
Once the project has been created, navigate to the project directory and run the (brief) test suite:
$ nosetests
5 tests should executed successfully - 1 error. If the tests succeeded, the next step is to initialise the quickwiki store by running the project setup script:
$ paster setup-app development.ini
Once the store has been inialised, start the Pylons web app with:
$ paster serve --reload development.ini
The Shabti Authkit Demo template’s variant on the standard Pylons welcome screen is browsable at at http://localhost:5000/ ...
The wiki page FrontPage which was created when paster setup-app development.ini is executed.
The drag’n’drop-to-delete List of Titles. The javascript seems to have stopped functioning. The codebase has moved on and it’s something you’d want to do in JQuery these days.
What can you say? It’s the “Hello Wiki” tutorial example spruced up to work with Pylons 0.9.7 and expressed in elixir.
author: | Graham Higgins <gjh@bel-epa.com> |
---|
September 06, 2010