.. _shabti_quickwiki:
|today|
.. _shabti-quickwiki:
**shabti_quickwiki** -- Pylons QuickWiki, using elixir
======================================================
.. rubric :: 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 `_
The Page model in vanilla SQLAlchemy
------------------------------------
Here is the Page model in vanilla SQLA.
.. code-block :: python
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)
The Page model in Elixir
------------------------
In this template, it is expressed in Elixir DSL:
.. code-block :: python
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
Using the template
------------------
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:
.. code-block :: bash
$ paster create -t shabti_quickwiki myproj
These are the option dialogue choices appropriate for the Shabti quickwiki template --- which uses mako templates and SQLAlchemy ...
.. code-block :: bash
(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:
.. code-block :: bash
$ 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:
.. code-block :: bash
$ paster setup-app development.ini
Once the store has been inialised, start the Pylons web app with:
.. code-block :: bash
$ 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/`` ...
Screen shots
^^^^^^^^^^^^
Welcome Page
++++++++++++
The standard welcome page (**myapp/public/index.html**)
.. image :: images/shabti_quickwiki_welcome.jpg
:align: center
Wiki FrontPage
++++++++++++++
The wiki page FrontPage which was created when ``paster setup-app development.ini`` is executed.
.. image :: images/shabti_quickwiki_frontpage.jpg
:align: center
QuickWiki page list
+++++++++++++++++++
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.
.. image :: images/shabti_quickwiki_titlelist.jpg
:align: center
Notes on the template
---------------------
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
|today|