Created
March 21, 2014 23:29
-
-
Save anonymous/9698670 to your computer and use it in GitHub Desktop.
template for iterator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iterator pairs*(s: TSession, request: TRequest, response:PResponse): tuple[key, value: string] = | |
## iterates over every (key, value) pair in the session `s`. | |
var sessionId: string | |
sessionId = getSessionId(request, response) | |
var list = session.redisCon.hGetAll("session:" & sessionId) | |
if not isNil(list): | |
var i = 0 | |
while i < list.len and not isNil(list[i]): | |
yield (list[i], list[i+1]) | |
i = i + 2 | |
template data*(s: TSession): expr = | |
bind pairs, session | |
session.pairs(request, response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment