Exemplo n.º 1
0
        print >>out, '<a class="more" href="?t=%d">&hellip;</a>' % thread.id
    print >>out, '</div>'

    print >>out, '<div class="footer"></div>'

    print >>out, '</div>'
    return out.getvalue()

def renderUserBox():
    out = StringIO()
    print >>out, '<div id="user">Welcome, %s!' % user.username
    print >>out, '<ul class="actions"><li><a href="session.py/logout">log out</a></li></ul>'
    return out.getvalue()

if __name__ == '__main__':
    argv = session.argv()
    if len(argv) < 3:
        print """Status: 400 Bad Request
Content-type: text/html

The request was nonsensical."""
        sys.exit()

    try:
        form = session.form()
        if argv[1] == 't':
            thread = Conversation.get(Conversation.user == user and Conversation.id == int(argv[2]))
            buf = renderThread(thread)
        elif argv[1] == 'e':
            event = Event.get(Event.inbox.user == user and Event.id == int(argv[2]))
            buf = renderEvent(event)
Exemplo n.º 2
0
import session
session.user(doLogin=False)

import os
import control
import json
import render
import calendar
import timeutil
import sys
from model import *
import config

user = session.user()
argv = session.argv()

def lastitem():
    try:
        latest = user.threads.order_by(Conversation.last_update.desc()).get().last_update
    except Conversation.DoesNotExist:
        latest = timeutil.getTime()
    return timeutil.toStamp(latest)

def updatedThreads(since):
    ref = timeutil.fromStamp(since)
    updThreads = user.threads.where(Conversation.last_update > ref)
    return [{'tid' : t.id,
             'events' : [
                {'eid'   : e.id,
                 'html'  : render.renderEvent(e)