)
## This is the way to do it in web.py 0.3+
-#app = web.application(urls, globals())
+app = web.application(urls, globals())
## Workaround for autoreloading and sessions when using web.config.debug = True
## Note: I don't actually use sessions
entries = map( readFile, filelist)
commentcounts = map(len, map( getCommentFiles, dates))
render = web.template.render(pwd + "/templates")
- # This mess is because web.py 0.2 doesn't include passing common useful functions to the template engine
- web.template.Template.globals['xrange'] = xrange
- web.template.Template.globals['len'] = len
- print render.multiday(zip(dates, entries, commentcounts), "Entries from %s" % theyear)
- # This is the web.py 0.3+ way to do it.
- #return render.multiday(dates, entries, "Entries from %s" % theyear)
+ return render.multiday(zip(dates, entries, commentcounts), "Entries from %s" % theyear)
class month:
def GET(self, theyear, themonth):
entries = map( readFile, filelist)
commentcounts = map(len, map( getCommentFiles, dates))
render = web.template.render(pwd + "/templates")
- web.template.Template.globals['xrange'] = xrange
- web.template.Template.globals['len'] = len
- print render.multiday(zip(dates, entries, commentcounts), "Entries from %s, %s" % (monthnames[themonth], theyear))
+ return render.multiday(zip(dates, entries, commentcounts), "Entries from %s, %s" % (monthnames[themonth], theyear))
class day:
def GET(self, year, month, day):
for f in files:
comments.append(loadComment(f))
render = web.template.render(pwd + "/templates")
- web.template.Template.globals['xrange'] = xrange
- web.template.Template.globals['len'] = len
- print render.day("%s-%s-%s" % (year, month, day), paras, comments)
+ return render.day("%s-%s-%s" % (year, month, day), paras, comments)
else:
render = web.template.render(pwd + "/templates")
- web.template.Template.globals['xrange'] = xrange
- web.template.Template.globals['len'] = len
- print render.noentry("%s-%s-%s" % (year, month, day))
+ return render.noentry("%s-%s-%s" % (year, month, day))
def verify(self, test):
if len(test) != 4:
s.sendmail("shortlog@zarvox.org", ["drew.m.fisher@gmail.com"], "To: Drew Fisher <drew.m.fisher@gmail.com>\nFrom: Shortlog <shortlog@zarvox.org>\nSubject: [shortlog] new comment on %s-%s-%s\n\nName: %s\nEmail: %s\nWebsite: %s\nComment: %s" % (year, month, day, name, email, website, comment ))
s.quit()
web.header('Content-Type', 'text/html')
- print "<html><body>Thanks! Your comment has been submitted and will be posted pending review.</body></html>"
-# paras = readFile(pwd + "/entries/" + year + "-" + month + "-" + day + ".txt")
-# render = web.template.render(pwd + "/templates")
-# web.template.Template.globals['xrange'] = xrange
-# web.template.Template.globals['len'] = len
-# print render.day("%s-%s-%s" % (year, month, day), paras)
-
+ return "<html><body>Thanks! Your comment has been submitted and will be posted pending review.</body></html>"
class pastyear:
def GET(self):
entries = map( readFile, filelist)
commentcounts = map(len, map( getCommentFiles, dates))
render = web.template.render(pwd + "/templates")
- web.template.Template.globals['xrange'] = xrange
- web.template.Template.globals['len'] = len
- print render.multiday(zip(dates, entries, commentcounts))
+ return render.multiday(zip(dates, entries, commentcounts))
class pastmonth:
def GET(self):
entries = map( readFile, filelist)
commentcounts = map(len, map( getCommentFiles, dates))
render = web.template.render(pwd + "/templates")
- web.template.Template.globals['xrange'] = xrange
- web.template.Template.globals['len'] = len
- print render.multiday(zip(dates, entries, commentcounts))
+ return render.multiday(zip(dates, entries, commentcounts))
class pastweek:
def GET(self):
entries = map( readFile, filelist)
commentcounts = map(len, map( getCommentFiles, dates))
render = web.template.render(pwd + "/templates")
- web.template.Template.globals['xrange'] = xrange
- web.template.Template.globals['len'] = len
- print render.multiday(zip(dates, entries, commentcounts))
+ return render.multiday(zip(dates, entries, commentcounts))
class redir:
def GET(self):
"timestamp": (mtime.isoformat() + "-06:00") }
entries.append(second)
render = web.template.render(pwd +"/templates")
- print render.feed(group_timestamp, entries)
+ return render.feed(group_timestamp, entries)
# web.py 0.3+ way
-#application = web.application(urls, globals()).wsgifunc()
+application = web.application(urls, globals()).wsgifunc()
# web.py 0.2 way
-application = web.wsgifunc(web.webpyfunc(urls, globals()))
+#application = web.wsgifunc(web.webpyfunc(urls, globals()))
if __name__ == "__main__":
## The web.py 0.3+ way
- #app.run()
+ app.run()
## The web.py 0.2 way
- web.run(urls, globals())
+ #web.run(urls, globals())