Beispiel #1
0
    def _submit(cls, title, url, author, sr, ip, spam = False):
        from admintools import admintools
        if url != u'self':
            try:
                l = Link._by_url(url, sr)
                raise LinkExists
            except NotFound:
                pass

        l = cls(title = title,
                url = url,
                _spam = spam,
                author_id = author._id,
                sr_id = sr._id, 
                lang = sr.lang,
                ip = ip)
        l._commit()

        clear_memo('link._by_url', Link, url, sr)
        # clear cache for lookups without sr
        clear_memo('link._by_url', Link, url, None)

        utils.worker.do(lambda: admintools.add_thing(l))

        return l
Beispiel #2
0
    def _new(cls, author, link, parent, body, ip, spam = False):
        c = Comment(body = body,
                    link_id = link._id,
                    sr_id = link.sr_id,
                    author_id = author._id,
                    ip = ip)

        c._spam = spam

        #these props aren't relations
        if parent:
            c.parent_id = parent._id

        c._commit()

        link._incr('num_comments', 1)

        if parent:
            to = Account._byID(parent.author_id)
            i = Inbox._add(to, c, 'inbox')

        #clear that chache
        clear_memo('builder.link_comments2', link._id)
        from admintools import admintools
        utils.worker.do(lambda: admintools.add_thing(c))

        return c
Beispiel #3
0
    def _new(cls, author, to, subject, body, ip, spam = False):
        m = Message(subject = subject,
                    body = body,
                    author_id = author._id,
                    ip = ip)
        m._spam = spam
        m.to_id = to._id
        m._commit()

        #author = Author(author, m, 'author')
        #author._commit()

        i = Inbox._add(to, m, 'inbox')

        from admintools import admintools
        utils.worker.do(lambda: admintools.add_thing(m))

        return m