示例#1
0
文件: logstream.py 项目: h2g2m/h2g2m
def get_logstream(request):
    if not request.usr: return []
    n = 10
    txts = DBSession.query(Txt).\
        order_by(Txt.creation_timestamp.desc()).\
        limit(n)
    annotations = DBSession.query(Annotation).\
        order_by(Annotation.creation_timestamp.desc()).\
        limit(n)
    
    log = []
    for txt in txts: 
        log.append(LogEntry(request, 'add_txt', txt.creator, txt))
    for annotation in annotations: 
        log.append(LogEntry(request, 'add_annotation', annotation.creator, annotation))
    log.sort(key=lambda x: x.data.creation_timestamp, reverse=True)
    return log[:n]
示例#2
0
文件: test_txt.py 项目: h2g2m/h2g2m
    def test_add(self):
        from h2g2m.views.txt import add
        from h2g2m.models.tables import Usr

        request = testing.DummyRequest()
        request.usr = DBSession.query(Usr).first()
        info = add(request)
        self.assertIsNotNone(info['form'])