Permalink
Browse files

render function works with 1 passed dict. beaker now works with redis…

…, but still need to update session functions to call beaker
  • Loading branch information...
1 parent 70649c7 commit 0ff80cf92f47c9cca423f28b20359bf3bc99964c @mhenstell committed Feb 24, 2011
Showing with 19 additions and 8 deletions.
  1. +14 −3 blog.py
  2. +5 −5 views/recent.tpl
View
17 blog.py
@@ -9,9 +9,12 @@
r = redis.Redis(host='localhost', port=6380, db=0)
session_opts = {
- 'session.type': 'cookie',
+ 'session.type': 'redis',
+ 'session.url': '127.0.0.1:6380',
'session.cookie_expires': 300,
- 'session.auto': True
+ 'session.auto': True,
+ 'cookie_domain': '.evildoin.gs',
+ 'key': 'evildoings'
}
app = SessionMiddleware(bottle.app(), session_opts)
@@ -23,8 +26,10 @@ def send_css(filename):
@bottle.route('/test')
def test():
s = bottle.request.environ.get('beaker.session')
+
s['test'] = s.get('test',0) + 1
s.save()
+
return 'Test counter: %d' % s['test']
@route("/")
@@ -42,7 +47,13 @@ def getRecentPosts():
posts = {}
for x in range(0, len(recentPosts)):
posts[x] = getPost(recentPosts[x])
- return template('recent', posts=posts, globalVars=globalVars)
+
+ #return template('recent', posts=posts, globalVars=globalVars)
+ return render('recent', posts)
+
+def render(type, dict):
+ refreshSession()
+ return template(type, passed=dict, globalVars=globalVars)
@route("/post")
def getPostPage():
View
@@ -1,16 +1,16 @@
-%for post in posts:
-
+%for post in passed:
+ %post=passed[post]
<article>
- <header>{{posts[post]['title']}}</header>
+ <header>{{post['title']}}</header>
<section id="dateline">
- Submitted By: {{posts[post]['user']}} on {{posts[post]['datestamp']}}
+ Submitted By: {{post['user']}} on {{post['datestamp']}}
</section>
<section id="body">
- {{posts[post]['body']}}
+ {{post['body']}}
</section>
</article>

0 comments on commit 0ff80cf

Please sign in to comment.