• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python memoize.clear_memo函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中r2.lib.memoize.clear_memo函数的典型用法代码示例。如果您正苦于以下问题:Python clear_memo函数的具体用法?Python clear_memo怎么用?Python clear_memo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了clear_memo函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _new

    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
开发者ID:cmak,项目名称:reddit,代码行数:27,代码来源:link.py


示例2: _submit

    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
开发者ID:cmak,项目名称:reddit,代码行数:25,代码来源:link.py


示例3: clear_account_by_name_cache

def clear_account_by_name_cache():
    q = Account._query(Account.c._deleted == (True, False), data = True)
    for account in q:
        name = account.name
        clear_memo('account._by_name', Account, name.lower(), True)
        clear_memo('account._by_name', Account, name.lower(), False)
        print "Cleared cache for %s" % account.name
开发者ID:AndrewHay,项目名称:lesswrong,代码行数:7,代码来源:clear_cache.py


示例4: set_amount

    def set_amount(cls, r, amount):
        old_amount = int(r._name)
        if old_amount != amount:
            r._name = str(amount)
            r._commit()
            
        #update the cache for the amount = 0 and amount = None cases
        rel = cls.rels[(r._thing1.__class__, r._thing2.__class__)]
        for a in set((old_amount, amount, None)):
            # clear memoizing around this thing's author
            if not r._thing2._loaded: r._thing2._load()
            if hasattr(r._thing2, "author_id"):
                clear_memo('report._by_author', cls, r._thing2.author_id,
                           amount = a)

            for t in (r._thing1, r._thing2):
                thing_key = cls._cache_prefix(rel, t.__class__,
                                              amount = a) + str(t._id)
                v = cache.get(thing_key)
                if v is not None:
                    if a == old_amount and old_amount != amount and r._id in v:
                        v.remove(r._id)
                    elif r._id not in v:
                        v.append(r._id)
                    cache.set(thing_key, v)
开发者ID:AndrewHay,项目名称:lesswrong,代码行数:25,代码来源:report.py


示例5: _new

    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)

        inbox_rel = None
        if parent:
            to = Account._byID(parent.author_id)
            # only global admins can be message spammed.
            if not c._spam or to.name in g.admins:
                inbox_rel = Inbox._add(to, c, 'inbox')

        #clear that chache
        clear_memo('builder.link_comments2', link._id)

        return (c, inbox_rel)
开发者ID:EmileKroeger,项目名称:lesswrong,代码行数:28,代码来源:link.py


示例6: register

def register(name, password, email):
    try:
        a = Account._by_name(name)
        raise AccountExists
    except NotFound:
        a = Account(name = name,
                    password = passhash(name, password, True))
        a.email = email

        a.confirmation_code = random_key(6)
        a.email_validated = False
        a.wiki_account = '__error__'

        a._commit()

        from r2.lib import emailer
        emailer.confirmation_email(a)

        if wiki_account.valid_name(name):
            def send_wiki_failed_email():
                emailer.wiki_failed_email(a)
            a.create_associated_wiki_account(password,
                                             on_request_error=send_wiki_failed_email)
        else:
            emailer.wiki_incompatible_name_email(a)

        # Clear memoization of both with and without deleted
        clear_memo('account._by_name', Account, name.lower(), True)
        clear_memo('account._by_name', Account, name.lower(), False)
        return a
开发者ID:JoshuaDavid,项目名称:lesswrong-1,代码行数:30,代码来源:account.py


示例7: userrel_remove

 def userrel_remove(self, user):
     fn = getattr(self, exists_name)
     s = fn(user)
     if s:
         s._delete()
         clear_memo(all_memo_str, self)
         clear_memo(reverse_memo_str, user)
         return True
开发者ID:cmak,项目名称:reddit,代码行数:8,代码来源:userrel.py


示例8: userrel_add

 def userrel_add(self, user):
     fn = getattr(self, exists_name)
     if not fn(user):
         s = relation(self, user, name)
         s._commit()
         clear_memo(all_memo_str, self)
         clear_memo(reverse_memo_str, user)
         return s
开发者ID:cmak,项目名称:reddit,代码行数:8,代码来源:userrel.py


示例9: delete

    def delete(self):
        self._deleted = True
        self._commit()
        clear_memo("account._by_name", Account, self.name.lower(), False)

        # remove from friends lists
        q = Friend._query(Friend.c._thing2_id == self._id, Friend.c._name == "friend", eager_load=True)
        for f in q:
            f._thing1.remove_friend(f._thing2)
开发者ID:Kenneth-Chen,项目名称:lesswrong,代码行数:9,代码来源:account.py


示例10: _new

 def _new(self, name, title, lang="en", type="public", over_18=False, **kw):
     try:
         sr = Subreddit._by_name(name)
         raise SubredditExists
     except NotFound:
         sr = Subreddit(name=name, title=title, lang=lang, type=type, over_18=over_18, **kw)
         sr._commit()
         clear_memo("subreddit._by_name", Subreddit, name.lower())
         clear_memo("subreddit.subreddits", Subreddit)
         return sr
开发者ID:cmak,项目名称:reddit,代码行数:10,代码来源:subreddit.py


示例11: _new

 def _new(self, name, **kw):
     tag_name = name.lower()
     try:
         tag = Tag._by_name(tag_name)
         raise TagExists
     except NotFound:
         tag = Tag(name = tag_name, **kw)
         tag._commit()
         clear_memo('tag._by_name', Tag, name.lower())
         return tag
开发者ID:Craigus,项目名称:lesswrong,代码行数:10,代码来源:link.py


示例12: register

def register(name, password):
    try:
        a = Account._by_name(name)
        raise AccountExists
    except NotFound:
        a = Account(name = name,
                    password = passhash(name, password, True))

        a._commit()
        clear_memo('account._by_name', Account, name.lower(), False)
        return a
开发者ID:vin,项目名称:reddit,代码行数:11,代码来源:account.py


示例13: register

def register(name, password):
    try:
        a = Account._by_name(name)
        raise AccountExists
    except NotFound:
        a = Account(name = name,
                    password = passhash(name, password, True))

        a._commit()
        # Clear memoization of both with and without deleted
        clear_memo('account._by_name', Account, name.lower(), True)
        clear_memo('account._by_name', Account, name.lower(), False)
        return a
开发者ID:EmileKroeger,项目名称:lesswrong,代码行数:13,代码来源:account.py


示例14: opt_in

 def opt_in(self, msg_hash):
     """Removes recipient of the email from the opt-out list"""
     email = self.get_recipient(msg_hash)
     if email:
         o = self.opt_table
         if self.has_opted_out(email):
             sa.delete(o, o.c.email == email).execute()
             clear_memo('r2.models.mail_queue.has_opted_out',
                        email)
             clear_memo('r2.models.mail_queue.opt_count')
             return (email, True)
         else:
             return (email, False)
     return (None, False)
开发者ID:Craigus,项目名称:lesswrong,代码行数:14,代码来源:mail_queue.py


示例15: opt_out

 def opt_out(self, msg_hash):
     """Adds the recipient of the email to the opt-out list and returns
     that address."""
     email = self.get_recipient(msg_hash)
     if email:
         o = self.opt_table
         try:
             o.insert().execute({o.c.email: email, o.c.msg_hash: msg_hash})
             clear_memo('r2.models.mail_queue.has_opted_out', 
                        email)
             clear_memo('r2.models.mail_queue.opt_count')
             return (email, True)
         except sa.exceptions.SQLError:
             return (email, False)
     return (None, False)
开发者ID:Craigus,项目名称:lesswrong,代码行数:15,代码来源:mail_queue.py


示例16: register

def register(name, password, email, create_wiki_account=True):
    try:
        a = Account._by_name(name)
        raise AccountExists
    except NotFound:
        a = Account(name = name,
                    password = passhash(name, password, True))
        a.email = email

        a.confirmation_code = random_key(6)
        a.email_validated = False

        a._commit()

        from r2.lib import emailer
        emailer.confirmation_email(a)

        # Clear memoization of both with and without deleted
        clear_memo('account._by_name', Account, name.lower(), True)
        clear_memo('account._by_name', Account, name.lower(), False)
        return a
开发者ID:arichard4,项目名称:eaforum,代码行数:21,代码来源:account.py


示例17: _new

    def _new(cls, author, link, parent, body, ip, spam = False, date = None):
        comment = Comment(body = body,
                          link_id = link._id,
                          sr_id = link.sr_id,
                          author_id = author._id,
                          ip = ip,
                          date = date)

        comment._spam = spam

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

        comment._commit()

        link._incr('num_comments', 1)

        inbox_rel = comment._send_post_notifications(link, comment, parent)

        #clear that chache
        clear_memo('builder.link_comments2', link._id)

        # flag search indexer that something has changed
        tc.changed(comment)

        #update last modified
        set_last_modified(author, 'overview')
        set_last_modified(author, 'commented')
        set_last_modified(link, 'comments')

        #update the comment cache
        from r2.lib.comment_tree import add_comment
        add_comment(comment)

        return (comment, inbox_rel)
开发者ID:MichaelBlume,项目名称:lesswrong,代码行数:36,代码来源:link.py


示例18: set_promoted

def set_promoted(link_names):
    # caller is assumed to execute me inside a lock if necessary
    g.permacache.set(promoted_memo_key, link_names)

    clear_memo(promoted_memo_key)
开发者ID:brendanlong,项目名称:lesswrong,代码行数:5,代码来源:promote.py



注:本文中的r2.lib.memoize.clear_memo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python menus.CommentSortMenu类代码示例发布时间:2022-05-26
下一篇:
Python media.thumbnail_url函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap