Another Hello Meme Entry
Adding to my last entry, and inspired by Sam Bull's Django entry, following is a QP web application framework-based entry in Eric Florenzano's multi-language programming meme.
The Meme
- Implement a program that takes in a user's name and their age, and prints hello to them once for every year that they have been alive.
- Post these rules, the source code for your solution, and the following list (with you included) on your blog.
- Bonus points if you implement it in a language not yet seen on the following list!
- [Python] http://www.eflorenzano.com/blog/post/trying-start-programming-meme
- [Bash] http://aartemenko.com/texts/bash-meme/
- [C] http://dakrauth.com/media/site/text/hello.c
- [Java] http://adoleo.com/blog/2008/nov/25/programming-meme/
- [Python 3] http://mikewatkins.ca/2008/11/25/hello-meme/
- [Ruby] http://stroky.l.googlepages.com/gem
- [Ruby] http://im.camronflanders.com/archive/meme/
- [Lisp] http://justinlilly.com/blog/2008/nov/25/back-on-the-horse/
- [JavaScript] http://www.taylanpince.com/blog/posts/responding-to-a-programming-meme/
- [Django] http://www.pocketuniverse.ca/archive/2008/november/27/florenzano-factor/
- [QP] http://mikewatkins.ca/2008/11/27/another-hello-meme-entry/
The Application
For a limited time you can access this "application" here: http://mikewatkins.ca:8111/
The Code
# ~/qp_sites/florenzano/slash.qpy
"""
An entry in Eric Florenzano's programming meme...
To run:
qp florenzano start
"""
from qp.fill.css import BASIC_FORM_CSS
from qp.fill.directory import Directory
from qp.fill.form import Form
from qp.pub.common import header, footer, page
from qp.pub.publish import DurusPublisher
class SitePublisher (DurusPublisher):
configuration = dict(
live_host='your_live_host',
durus_address=('localhost', 7011),
http_address=('', 8011),
)
class SiteDirectory(Directory):
def get_exports(self):
yield ('', 'hello', 'Hello', None)
def hello:xml(self):
form = Form()
form.add_string("name", title="Your name", size=20,
required=True)
form.add_int("age", title="Your age", required=True)
form.add_submit("Say Hello")
if not form.is_submitted() or form.has_errors():
return page('Say hello', form.render(),
style=BASIC_FORM_CSS)
# The form has been submitted
header('QP hello example')
'<ul>'
for age in range(form.get('age')):
'<li>%s) Hello, %s.</li>' % (age, form.get('name'))
'</ul>'
'<p><a href="">Try again...</a></p>'
footer()